Method: Resto::Format::Xml.encode
- Defined in:
- lib/resto/format/xml.rb
.encode(hash, options = nil) ⇒ String
Converts a Hash to a XML formatted String.
Example:
Xml.encode({ root: { body: 'I am a body' } })
# => "<?xml version=\"1.0\"?><root><body>I am a body</body></root>"
75 76 77 |
# File 'lib/resto/format/xml.rb', line 75 def encode(hash, = nil) Nokogiri::XML::Builder.new { |xml| to_xml(hash, xml) }.to_xml end |