Search code examples
pythonxmlminidom

Python: xml.dom.minidom empty nodeValue nonempty toxml() value


I have a line that gets the nodeValue of a Node:

parent.getElementsByTagName("Url")[0].nodeValue

that returns nothing:

<br/>

When I do:

parent.getElementsByTagName("Url")[0].toxml()

it returns:

< Url>www.something.com< /Url>

I am not sure what is going on here. Another data point: when I do nodeName instead of nodeValue it returns, as expected, Url.

Any thoughts?


Solution

  • Try this:

    parent.getElementsByTagName('Url')[0].childNodes[0].nodeValue