Introducing the PrettyXML gem
require 'pretty-xml'
include PrettyXML
xml = "<a1><b1>testing</b1><c>eating<c1>apple</c1>and cooking</a1>"
puts write xml
=begin
output:
<?xml version="1.0" encoding="UTF-8"?>
<a1>
<b1>testing</b1>
<c>
eating
<c1>apple</c1>
and cooking
</c>
</a1>
=end
The PrettyXML gem is a module for use within your own object which needs XML to be pretty.