Add new element
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 })
agenda = meeting.add_element 'agenda'
doc.children[1]
item1 = agenda.add_element 'item'
puts doc.children[1]
item1.text = 'new Test'
puts doc.children[1]
doc.write
Related examples in the same category