Monday, 2 March 2015

unable to parse graphml file with elementtree



xml



<?xml version="1.0" encoding="UTF-8"?>
<graphml xmlns="http://ift.tt/QM36aN"
xmlns:xsi="http://ift.tt/ra1lAU"
xsi:schemaLocation="http://ift.tt/1guo4q0">
<graph id="G" edgedefault="undirected">
<node id="n0"/>
<node id="n1"/>
<edge id="e1" source="n0" target="n1"/>
</graph>
</graphml>


python code



tree = ET.parse(my_file.xml).getroot()

print tree.findall('graph') # returns []


If I remove the attributes from the graphml tag, then it works, returns the element


No comments:

Post a Comment