使用 Python 使用 minidom 获取元素值 [英] Get Element value with minidom with Python
本文介绍了使用 Python 使用 minidom 获取元素值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在用 Python 为 Eve Online API 创建一个 GUI 前端.
I am creating a GUI frontend for the Eve Online API in Python.
我已经成功地从他们的服务器中提取了 XML 数据.
I have successfully pulled the XML data from their server.
我正在尝试从名为name"的节点获取值:
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?
推荐答案
应该是
name[0].firstChild.nodeValue
这篇关于使用 Python 使用 minidom 获取元素值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文