Parsing Gxl In Python
I need to parse a GXL file (a kind of XML for graph representation) into python. I have the simplest example: V
Solution 1:
The built-in xml.etree.ElementTree
would makes things a bit easier. Example:
import xml.etree.ElementTree as ETtree= ET.parse("filename")
for node in tree.findall(".//node/attr/string"):
node_value = node.text
dw(node_value)
Solution 2:
Just in case anyone looked for it later, here is how my dk (for reading multiple tags) works with the same xml.etree.ElementTree library:
for edge in tree.findall(".//edge"):
start= edge.get('from')
end= edge.get('to')
dk(start,end)
Post a Comment for "Parsing Gxl In Python"