From: Robert Klemme Date: 2009-09-25T22:13:27+09:00 Subject: Re: Ordering XML Attributes with Hpricot? 2009/9/25 Lance Pollard : > This means though I have to do two passes on the XML: > > 1) Modify the nodes with data the way nokogiri or hpricot do it (xpath > and whatnot) > 2) Format the xml using regular expression on pure strings, not using > the xml parsing engines. > > Is that correct? I would not work on the output XML via String replacements. I would rather adjust the output process. For example, if you would be working with REXML you could implement a Formatter which outputs attributes in a particular order. I don't know whether this can be done with Nokogiri or Hpricot as well or as easily. Kind regards robert require 'rexml/document' class OrderedAttributes < REXML::Formatters::Pretty def write_element(elm, out) att = elm.attributes class < -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/