Для следующего XML:
Код: Выделить всё
print(json.dumps(xmltodict.parse("""
...
...
... elements
... more elements
...
...
... element as well
...
...
... """), indent=4))
Код: Выделить всё
{
"mydocument": {
"@has": "an attribute",
"@also": "an attribute",
"and": {
"many": [
"elements",
"more elements"
]
},
"plus": {
"@a": "complex",
"#text": "element as well"
}
}
}
Код: Выделить всё
{
"mydocument": {
"Attributes": {"@has": "an attribute", "@also": "another attribute"},
"and": {
"many": [
"elements",
"more elements"
]
},
"plus": {
"Attributes": {"@a": "complex"},
"#text": "element as well"
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/791 ... dictionary
Мобильная версия