Python:xml.dom.minidom 空 nodeValue 非空 toxml() 值
我有一行获取节点的 nodeValue:
parent.getElementsByTagName("Url")[0].nodeValue
不返回任何内容:
<br/>
当我这样做时:
parent.getElementsByTagName("Url")[0].toxml()
它返回:
< Url>www.something.com< /Url>
我不确定这里发生了什么。另一个数据点:当我执行nodeName而不是nodeValue时,它按预期返回Url。
有什么想法吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
试试这个:
Try this:
DOM Level 2 文档指出元素节点的
nodeName
是标签名称,nodeValue
始终为null
并且attributes
是NamedNodeMap
,因此此代码的行为符合预期。The DOM Level 2 documentation states that
nodeName
for an element node is the tag name, thenodeValue
is alwaysnull
andattributes
is aNamedNodeMap
, so this code behaves as expected.