orders_xml = %{
<orders>
<order>
<number>1</number>
<date>02/10/2008</date>
<customer>C</customer>
<items>
<item upc="0" desc="Roses" qty="240" />
<item upc="1" desc="Candy" qty="160" />
</items>
</order>
</orders>}
require 'rexml/document'
orders = REXML::Document.new(orders_xml)
my_order = orders.root.elements[1]
first_node = my_order.elements[1]
first_node.name # => "number"
first_node.next_element.name # => "date"
first_node.parent.name # => "order"
|