From: Jon Hart Date: 2011-12-20T07:21:27+09:00 Subject: Re: Nokogiri::XML::Builder XML attribute ordering --f46d040890fde93e6204b4795e88 Content-Type: text/plain; charset=ISO-8859-1 It appears that the same problem exists with Builder. From http://builder.rubyforge.org/: "The order that attributes are inserted in markup tags is undefined." Interestingly, though, the _special method exists, which is used by Builder itself to enforce the ordering of XML attributes in the XML processing instruction typically found on the first line of an XML file. In this case, they ensure that the order is version, encoding, standalone: def instruct!(directive_tag=:xml, attrs={}) _ensure_no_block ::Kernel::block_given? if directive_tag == :xml a = { :version=>"1.0", :encoding=>"UTF-8" } attrs = a.merge attrs @encoding = attrs[:encoding].downcase end _special( "", nil, attrs, [:version, :encoding, :standalone]) end -jon --f46d040890fde93e6204b4795e88--