[Ruby]format xml with Ruby
require "rubygems" require "nokogiri" def prettify(xml_file, new_filename) doc = Nokogiri::XML( File.open(xml_file) ) File.open(new_filename, 'w') do |f| f.puts doc.to_xml end end
来源:https://stackoverflow.com/questions/12598530/format-an-xml-string-in-ruby