Creating and Modifying XML Documents
require 'rexml/document'
doc = REXML::Document.new
meeting = doc.add_element 'meeting'
meeting_start = Time.local(2006, 10, 31, 13)
meeting.add_element('time', { 'from' => meeting_start,
'to' => meeting_start + 3600 })
doc.children[0] # => <meeting> ... </>
puts doc.children[0].children[0]
puts doc.children[0] # => <?xml ... ?>
puts doc.children[1] # => <meeting> ... </>
Related examples in the same category