0
我正在尝试使用ElementTree
模块解析Python中的XML文档。我正在寻找Elements
,该标签中的xml标签为entry
,name
属性为ipAddress
。下面是我到目前为止的代码:搜索名称属性的XML标签:Python elementTree模块
tree = ET.parse(fi2)
root = tree.getroot()
for child in root.iter('entry'): #looks through child elements for tag=entry
#look for elements that have an attribute(name)='string'
作为参考,当我使用for
循环内的代码print child.tag, child.attrib
,我得到下面的输出:
entry {'name': 'ipAddress'}
我需要帮助寻找entry
标签用的ipAddress