Python提取xml中的字段

来源:互联网 发布:海天盛筵 知乎 编辑:程序博客网 时间:2024/05/19 14:37
#encoding=utf-8from xml.etree import ElementTree as ETfile=ET.parse('c_515.xml')f=file.findall('/file')for x in f:    print x.attribprintfor onename in f:  #找出file节点    for child in onename.getchildren(): #找出file节点的子节点        print child.text        break        print '############'

工作中统计xml中的某个字段,临时写的,参考自:

http://www.open-open.com/lib/view/open1329403902937.html

0 0
原创粉丝点击