Python xml 转 dict 转 json
import json
import xmltodict
d = xmltodict.parse("""
<mydocument has="an attribute">
<and>
<many>elements</many>
<many>more elements</many>
</and>
<plus a="complex">
element as well
</plus>
</mydocument>
""")
print(json.dumps(d, indent=4))
xml_res = xmltodict.unparse(d, pretty=True)
print(xml_res)
还没有评论,来说两句吧...