It isn't a work around, but one of the many correct ways to work with  
XML,
XSLT
XML is a big topic area, but in practice it is often either documents  
or hashes (associative arrays)
As stated by another, XML elements are only ordered by the nesting.
For an example of how this looks, export a playlist from iTunes as  
XML and then look at the XML file. It isn't immediately as human- 
friendly as you might expect. However, the data structures are very  
easy to manipulate.
iTunes' interface is a great example of how you can push XML data  
around and make it do things and appear different ways.
Simple key/value coding (hash, or associative array) works well as  
XML and can be very easy to manipulate with simple array functions  
(or methods) for sorting by alpha-numeric or by size or other things.

XML is intended to be a human-readable data format in a sense, but it  
is also intended to be manipulated for presentation to most users.

Load your data into arrays (hashes) then you can order it however you  
want to for immediate use.
If you really need some ordering, you have to load it into an array  
or search it to sort and then serialize it by writing it to another  
format (like YAML) or to a database table.
XML is nice but not always the best data format.
Sometimes inherently ordered data is necessary. But not very.
On Mar 19, 2007, at 7:40 PM, caritos wrote:

> Is there any way of specify the order of the attributes in REXML.  I
> can't find any way of doing this in the documentation.
>
> The two methods that I found "add_attribute(key, value=nil)" and
> "add_attributes(hash)" provides no way of specifying the order.
>
> When I output my xml document to a file or stdout, the order of the
> attributes are in a different order.  Any work around for this  
> problem?
>
>