python学习:操作xml

import xml.etree.ElementTree  as ET


tree=ET.parse('demo.xml')
root=tree.getroot()

for child in root:
    print(child.tag,child.attrib)
    for i in child:
        print(i.tag,i.text)

 

posted @ 2017-02-20 15:23  alston-lee  阅读(89)  评论(0编辑  收藏  举报