problem in ElementTree SubElement
Fredrik Lundh
fredrik at pythonware.com
Mon Feb 6 12:48:10 EST 2006
Sbaush wrote:
> I would get this element in xml:
>
> <date month="02" day="06" />
>
> I have write this:
>
> date=ET.SubElement(idsreq,"date")
> date.set("month",month)
> date.set("day",day)
>
> but i get this:
>
> <date day="06" month="02" />
>
> The attributes are not in my order!!
> how i can get the attributes in right order???
XML attributes are not ordered.
the default ET writer sorts the attributes in lexical order, to guarantee con-
sistent output. rolling your own writer won't help, since Python's dictionaries
don't preserve the order either.
</F>
More information about the Python-list
mailing list