From: Axel Etzold Date: 2009-09-25T06:34:56+09:00 Subject: Re: Ordering XML Attributes with Hpricot? Dear Lance, I accidentally hit the "send" button too early: > > Since the attributes are kept in a hash there's no order to them, so > they appear in seemingly random order, but it's the same random order > consistently. > > Any ideas how to do that? > a Hash can be sorted to give an Array with Hash#sort : http://ruby-doc.org/core/classes/Hash.html#M002865 > And is there a way to say "after two attributes, make a new line". So I > can print out xml that can be edited by humans like code. You can then iterate through the Array with Array#each_with_index, eg. my_array.each_with_index{|x,i| if i%2==0 ; p x + "\n"; else p x; end} Best regards, Axel -- Neu: GMX Doppel-FLAT mit Internet-Flatrate + Telefon-Flatrate f�r nur 19,99 Euro/mtl.!* http://portal.gmx.net/de/go/dsl02