Re: problem in ElementTree SubElement

"Fredrik Lundh" <[email protected]>
Newsgroups gmane.comp.python.general,gmane.comp.python.xml
Message-ID <[email protected]>
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>



-- 
http://mail.python.org/mailman/listinfo/python-list
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.