Create an XML document from a here document : XML Builder « XML « Ruby






Create an XML document from a here document


#!/usr/bin/env ruby

require 'rexml/document'
include REXML

address = <<XML
<address>
 <name><given>A</given><family>B</family></name>
 <street>9876 St.</street>
 <city>CA</city>
 <state>Colorado</state>
 <code>81000</code>
 <country>USA</country>
</address>
XML

document = Document.new( address )
puts document

 








Related examples in the same category

1.Builder::XmlMarkup.new( :target => address, :indent => 1 )
2.Use builder to create an XML document from hash
3.XmlMarkup