From: Phrogz Date: 2007-11-24T03:15:05+09:00 Subject: Re: read a xml file On Nov 23, 6:14 am, Bulhac Mihai wrote: > hello, im new in using rexml and a i have a first question: how can a > read this file: > > > > > > > > > > > > > > > > > > > > > > i want to read all children so that output will be something like that: > drive C > folder folder1 > subfolder sub1 > subfolder sub2 > file file1 > file file2 > subfoler sub3 > folder folder2 > file file1 > file file2 Note that I had to fix your XML - you were missing a closing tag for one of your files. def show_item( rexml_element, level=0 ) print " "*level puts "#{rexml_element.name} #{rexml_element.attributes['name']}" rexml_element.elements.each{ |el| show_item( el, level+1 ) } end require 'rexml/document' doc = REXML::Document.new( DATA.read ) show_item( doc.root ) __END__