From: Jon Hart Date: 2011-12-17T04:00:34+09:00 Subject: Nokogiri::XML::Builder XML attribute ordering --f46d042f96cc11ef8104b43a37bd Content-Type: text/plain; charset=ISO-8859-1 Hello, Just to get it out of the way, yes, I've searched the lists and yes, I am well aware that attribute ordering in XML elements shouldn't matter. Additionally, yes, I am well aware of the Nokogiri mailing list, however Google won't let me join the group and I can't post without joining. So, here I am. However, my use case is slightly different. The code I am using that ultimately writes XML files will switch the ordering of XML attributes that it generates depending on what version of Ruby is used to run the code, what state the code is in, etc. The end result is that if I had an XML file A with the following content at time 0: At time > 0, where this file is regenerated either on a different machine, with ever so slightly modified code (but the order as defined with the Builder is the same), the order changes. When these resulting files are in some sort of revision control, it looks like they are changing on a regular basis but in reality its just the attribute ordering. Does anyone have any tried and true solutions that enforce ordering of XML attributes with Nokogiri::XML::Builder? I have had some level of success with the following practice: stub_xml = "" stub_xml += "" stub_xml += " builder = Nokogiri::XML::Builder.with(Nokogiri::XML(stub_xml).at("Foo") do |xml| # usual builder stuff here end This only works for really simple XML, and for XML that is deeply nested, the "stub" XML becomes so large that I often just end up writing the XML generation code by hand. Any suggestions would be appreciated! Please note that I am not tied to Nokogiri::XML::Builder for XML building. I have heard that I can accomplish something similar with Rexml. Thanks, -jon --f46d042f96cc11ef8104b43a37bd--