Python script - sort XML elements with the same tag, but with no attributes

Viewed 41

is it possible via xml.etree.ElementTree to sort XML attributes with the same tag (but with no attributes provided)? For example:

<?xml version="1.0" encoding="utf-8"?>
<tns:service xmlns:tns="somenamespace">
    <tns:info>
        <tns:date>1635799858045</tns:date>
        <tns:type>update</tns:type>
    </tns:info>
    <tns:info>
        <tns:date>1633489659638</tns:date>
        <tns:type>add</tns:type>
    </tns:info>
    <tns:info>
        <tns:date>1637231504666</tns:date>
        <tns:type>approved</tns:type>
    </tns:info>
</tns:service>

Is there a way I can sort <tns:info> tags according to their <tns:date>?

Thank you

0 Answers
Related