Phrogz
12/12/2007 12:06:00 AM
On Dec 11, 4:59 pm, Carl Bourne <carl.bou...@intellect.co.uk> wrote:
> I would like to process an XML file using REXML and recurse down through
> some sub elements, e.g. the "group" and "cond" elements in the following
> XML:
[snip]
> However, I need to produce output that maintains the hierarchy so it can
> be displayed as a nested list such as:-
def show_element( element, level=0 )
print " "*level
# do something with the element here
# Depth-first recursion
element.children.each{ |child|
show_element( child, level+1 )
}
end