From: Phlip Date: 2009-03-11T13:43:05+09:00 Subject: Re: how to get all attributes in an element Naresh Ramaswamy wrote: > Thank you for the solution, it almost worked to me, but when I apply it > on my xml document I am getting the output from reverse order, why so? > uri='tel:naresh@span.com'/> > I applied the code for the element "REMOVE_1" and observe the following > as the output. > > -----output------ > tel:naresh@span.com > InVIte > req_line > ----------------- XML has a concept of document order, but not of attribute order within one tag. XML readers are (apparently) not required to remember there order. Next, the attributes come in a Hash, and this has a BUG (!) which will be FIXED (!) in the next Ruby versions. It can't preserve the order you inserted its keys. Until then, your own code must put the keys into the order you need. Try element.attributes.to_a.sort to put them into asciibetic order, for example.