[issue34160] ElementTree not preserving attribute order
Stefan Behnel
report at bugs.python.org
Sat Mar 16 17:27:17 EDT 2019
Stefan Behnel <stefan_ml at behnel.de> added the comment:
Something like this:
def sort_attributes(root):
for el in root.iter():
attrib = el.attrib
if len(attrib) > 1:
attribs = sorted(attrib.items())
attrib.clear()
attrib.update(attribs)
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34160>
_______________________________________
More information about the Python-bugs-list
mailing list