tree = ET.parse("Result.xml")
root = tree.getroot()
print type(root)
print root.tag # 得到root 标签
print root.text #得到标签的值
print root.attrib

def parserResultXml(xmlfile):
tree = ET.parse(xmlfile)
result = tree.getroot()[0][1]
for child in result:
if child.tag == "description":
pass
elif child.tag == "name":
pass
elif child.tag == "passIndex":
pass
elif child.tag == "benchmarkRunId":
pass
else:
print child.tag +":"+child.text

if __name__ == '__main__':
parserResultXml("Result.xml")

学习网址:
https://docs.python.org/2.7/library/xml.etree.elementtree.html#module-xml.etree.ElementTree

相关文章:

  • 2022-12-23
  • 2021-12-01
  • 2021-10-11
  • 2022-01-22
  • 2021-06-08
  • 2021-12-17
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-07
  • 2022-12-23
  • 2022-12-23
  • 2021-07-17
  • 2022-02-01
  • 2021-07-30
相关资源
相似解决方案