xmltodict
xmltodict copied to clipboard
Keep Text order after parsing if there is an ordereddict between them
Example XML that are full of HTML tags:
<p>XXXXXXX <a href="url" type="external">123456</a>: YYYYYYY</p>
currently, when I parse this xml , it shows
OrderedDict([('p', [OrderedDict([('a', OrderedDict([('@href', 'url'), ('@type', 'external'), ('#text', '123456')])), ('#text', XXXXXXXXYYYYYY')]) , which combines the texts in #text
XXXXXX and YYYYY are combined which is not the xml element order.
Is there a way to parse xml to #text,OrderedDict[a],#text rather then OrdererDict[a] and #text ?
<p>XXXXXXX <a href="url" type="external">123456</a>: YYYYYYY</p>
maybe converted to:
{
"p": {
"#text": "XXXXXXX ",
"a": {
"-href": "url",
"-type": "external",
"#text": "123456"
},
"#text1": ": YYYYYYY"
},
"#omit-xml-declaration": "yes"
}
or maybe convert to a list :
{p: ["XXXX",{"a": {...}},"YYYYYY"]}
However much I would like to use xmltodict, this issue makes it a no-go :/