When I create a document using the mini-disk, the attributes are sorted alphabetically in the element. Take this example from here :
from xml.dom import minidom
xml = minidom.Document()
userElem = xml.createElement("user")
userElem.setAttribute("name", "Sergio Oliveira")
userElem.setAttribute("nickname", "seocam")
userElem.setAttribute("email", "seocam@taboca.com")
userElem.setAttribute("photo","seocam.png")
xml.appendChild(userElem)
print xml.toprettyxml()
The result is the following:
<?xml version="1.0" ?>
<user email="seocam@taboca.com" name="Sergio Oliveira" nickname="seocam" photo="seocam.png"/>
That is all very well if you wanted to use the attributes in the letter / name / pseudonym / order of the photo instead of the name / nickname / email address / order of photos as they are created.
How do you get the attributes to display in the order in which you created them? Or, how do you generally control the order?
source
share