ActiveSupport、Hash#to_xml
>> require "rubygems" => true >> require "active_support" => true >> Hash.from_xml([{:foo => 1, :bar => 2}, {:baz => 3}].to_xml).to_xml => "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<hash>\n <records type=\"array\">\n <record>\n <foo type=\"integer\">1</foo>\n <bar type=\"integer\">2</bar>\n </record>\n <record>\n <baz type=\"integer\">3</baz>\n </record>\n </records>\n</hash>\n"