我在Python中使用dicttoxml将dict转换为XML。将字典转换为具有属性的XML
我需要将字典转换为XML属性。
例如:
字典
[
{
"@name":"Ravi",
"@age":21,
"college":"Anna University"
}
]
输出XML
<Student name="Ravi" age=21>
<college>Anna University</college>
</Student>
代码
dicttoxml(dict, custom_root='Student', attr_type=False, root=True)
实际输出
<Student>
<key name="name">Ravi</key>
<key name="age">21</key>
<college>Anna University</college>
</Student>