Reputation: 22238
I'm using Hpricot for traversing an XML packet. For each node I'm on, I want to get a list of the immediate children . However when using
(current_node/:section)
I'm getting ALL descendant sections, not just the immediate children.
How can I get around this?
Upvotes: 1
Views: 262
Reputation: 176412
From the documentation:
If you’re looking for a single element, the at method will return the first element matched by the expression. In this case, you’ll get back the element itself rather than the Hpricot::Elements array.
Does the following works for you?
current_node.at(:section)
If you prefer, you can also use the xpath child operator.
Upvotes: 0