赞
踩
import xml.etree.ElementTree as ET
tree = ET.parse('example.xml')
root = tree.getroot()
for child in root:
print(child.tag, child.attrib)
from lxml import etree
tree = etree.parse('example.xml')
root = tree.getroot()
for child in root:
print(child.tag, child.attrib)
import xmltodict
data = xmltodict.parse('example.xml')
print(data['root']['child'])
import dicttoxml
data = {'root': {'child': 'value'}}
xml = dicttoxml.dicttoxml(data)
print(xml)
import xml.dom.minidom as minidom
dom = minidom.parse('example.xml')
root = dom.documentElement
for child in root.childNodes:
print(child.tagName, child.attributes)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。