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: [<DOM Element: tspan at 0x10392c6d0>]
nodeName: tspan
nodeValue: None
childNodes: [<DOM Text node "'MY STRING'">]
nodeName: #text
nodeValue: MY STRING
childNodes: ()
nodeName: text
nodeValue: None
childNodes: [<DOM Element: tspan at 0x10392c800>]
nodeName: tspan
nodeValue: None
childNodes: [<DOM Text node "'MY WORDS'">]
nodeName: #text
nodeValue: MY WORDS
childNodes: ()
I used xml.dom.minidom, the various fields are explained on this page, MiniDom Python.