#encoding=utf-8
from xml.etree import ElementTree as ET
file=ET.parse('c_515.xml')
f=file.findall('/file')
for x in f:
print x.attrib
print
for 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