From: Phrogz Date: 2007-12-12T09:10:02+09:00 Subject: Re: Recursing XML data using REXML On Dec 11, 4:59 pm, Carl Bourne 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