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

tom*_*tom 6 python xml minidom

我有一行获取Node的nodeValue:

parent.getElementsByTagName("Url")[0].nodeValue
Run Code Online (Sandbox Code Playgroud)

什么都不返回:

<br/>
Run Code Online (Sandbox Code Playgroud)

当我做:

parent.getElementsByTagName("Url")[0].toxml()
Run Code Online (Sandbox Code Playgroud)

它返回:

< Url>www.something.com< /Url>
Run Code Online (Sandbox Code Playgroud)

我不确定这里发生了什么.另一个数据点:当我执行nodeName而不是nodeValue时,它会按预期返回Url.

有什么想法吗?

Att*_* O. 6

试试这个:

parent.getElementsByTagName('Url')[0].childNodes[0].nodeValue
Run Code Online (Sandbox Code Playgroud)