用minidom获取元素值 [英] Get Element value with minidom with Python
本文介绍了用minidom获取元素值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经从他们的服务器上成功地提取了XML数据。
我试图从一个名为name的节点获取值:
从xml。 dom.minidom import parse
dom = parse(C:\\\eve.xml)
name = dom.getElementsByTagName('name')
打印名称
这似乎找到了节点,但输出如下:
[< DOM元素:名称在0x11e6d28>]
如何得到它来打印节点的值?
解决方案
应该只是
name [0] .firstChild.nodeValue
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 a node called "name":
from xml.dom.minidom import parse
dom = parse("C:\\eve.xml")
name = dom.getElementsByTagName('name')
print name
This seems to find the node, but the output is below:
[<DOM Element: name at 0x11e6d28>]
How could I get it to print the value of the node?
解决方案
It should just be
name[0].firstChild.nodeValue
这篇关于用minidom获取元素值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文