From: Keith Fahlgren Date: 2007-06-08T02:50:12+09:00 Subject: Re: Builder gem - xml attributes ordering On 6/7/07, Arunprabu Durairaju wrote: > Hi Johnson, > > I understand that it is not specified in the XML specification and it is > not a requirement generally. > > I also checked with REXML and it has the same behaviour as Builder. Yeah, I'm sure they both use Hashes internally for attributes (and Hashes are unordered in Ruby). However, it'd be easy to modify the attribute insertion in Builder to take an Array instead. This is what you'll have to change: gems/builder-2.0.0/lib/builder/xmlmarkup.rb # Insert the attributes (given in the hash). def _insert_attributes(attrs, order=[]) return if attrs.nil? order.each do |k| v = attrs[k] @target << %{ #{k}="#{_attr_value(v)}"} if v end attrs.each do |k, v| @target << %{ #{k}="#{_attr_value(v)}"} unless order.member?(k) end end Keith