Is there a way to keep order of mixed and repeating tags?
See original GitHub issueExample 🍔
<DoubleCheeseburger>
<Bread/>
<Cheese/>
<Beef/>
<Cheese/>
<Beef/>
<Bread/>
</DoubleCheeseburger>
import xmltodict, json
data = xmltodict.parse(double_cheeseburger_xml)
print(json.dumps(data, indent=3))
{
"DoubleCheeseburger": {
"Bread": [
null,
null
],
"Cheese": [
null,
null
],
"Beef": [
null,
null
]
}
}
Can we tell the order of each Bread
, Cheese
and Beef
with respect to each other not only within the same tag, but also in the parent node (DoubleCheeseburger
)?
If not, is there a way to monkeypatch to write it down?
Issue Analytics
- State:
- Created 8 years ago
- Reactions:1
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Does the order of tags matter? - Meta Stack Exchange
No, the order you add the tags doesn't matter because you don't actually get to set the order of the tags. Tag order...
Read more >Repeat item labels in a PivotTable - Microsoft Support
Right-click the row or column label you want to repeat, and click Field Settings. Click the Layout & Print tab, and check the...
Read more >order - CSS: Cascading Style Sheets - MDN Web Docs
Since order is only meant to affect the visual order of elements and not their logical or tab order. order must not be...
Read more >Etsy SEO: Should you repeat keywords? - TIZZIT
You will have to look at the keyword data and figure out how the keyword mix at the listing level will work together...
Read more >Shuffle an array with python, randomize array item order with ...
Advantage: You can random multiple arrays simultaneously without disrupting the mapping. And 'random_state' can control the shuffling for reproducible ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@andreif: I needed the same feature and wrote a patch for that, the branch is on my fork here: https://github.com/lindsay-stevens/xmltodict/tree/ordered-children-short-tags
It’s got a flag to deal with mixed child ordering on parse and unparse. During parse it’ll add an @order attribute, on unparse it’ll remove the attribute and sort the mixed nodes. Also has a bonus XHTML-ish feature to enable output of short-form of empty tags, e.g. “<tag/>” vs. “<tag></tag>”
Not opened a PR for it yet since my previous one is still open and I didn’t want to be annoying.
Some services do require certain order of children unfortunately.