Topic: Hpricot and a 3 level deep node XML

http://errtheblog.com/post/8 has an example of a root level node and a way of parsing it for xml.

Can anyone point me to an example digging through a 3 node level? How do you iterate through it?

# 1 node sample iteration
(doc/:product).each do |xml_product|
  product = Product.new
  for field in FIELDS
    product[field] = (xml_product/field.intern).first.innerHTML
  end
  product.save
end

# 3 node sample
<Export>
  <Product>
    <SKU>403276</SKU>
    <ItemName>Trivet</ItemName>
    <Desc>
      <More>Trivet</More>
      <State>
        <Code>NY</Code>
        <Name>New York</Name>
      </State>
    </Desc>
    <CollectionNo>0</CollectionNo>
    <Pages>0</Pages>
  </Product>
</Export>

Last edited by shajused (2007-10-12 14:15:18)

=====================
Sam G.