I am creating a GUI frontend for the Eve Online API in Python.
I have successfully pulled the XML data from their server.
I am trying to grab the value from
The above answer is correct, namely:
name[0].firstChild.nodeValue
However for me, like others, my value was further down the tree:
name[0].firstChild.firstChild.nodeValue
To find this I used the following:
def scandown( elements, indent ):
for el in elements:
print(" " * indent + "nodeName: " + str(el.nodeName) )
print(" " * indent + "nodeValue: " + str(el.nodeValue) )
print(" " * indent + "childNodes: " + str(el.childNodes) )
scandown(el.childNodes, indent + 1)
scandown( doc.getElementsByTagName('text'), 0 )
Running this for my simple SVG file created with Inkscape this gave me:
nodeName: text
nodeValue: None
childNodes: []
nodeName: tspan
nodeValue: None
childNodes: []
nodeName: #text
nodeValue: MY STRING
childNodes: ()
nodeName: text
nodeValue: None
childNodes: []
nodeName: tspan
nodeValue: None
childNodes: []
nodeName: #text
nodeValue: MY WORDS
childNodes: ()
I used xml.dom.minidom, the various fields are explained on this page, MiniDom Python.