From: Brian Marick Date: 2007-11-23T22:33:57+09:00 Subject: Re: read a xml file On Nov 23, 2007, at 7: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'd use xml-simple. % gem install xml-simple Then a program like this: require 'xmlsimple' require 'pp' pp XmlSimple.xml_in('xml.xml') will produce this structure of hashes and arrays: {"name"=>"c", "folder"=> [{"name"=>"folder1", "subfolder"=> [{"name"=>"sub1", "content"=>"\n "}, {"name"=>"sub2", "file"=>[{"name"=>"file1"}, {"name"=>"file2"}]}, {"name"=>"sub3", "file"=>[{"name"=>"file1"}]}]}, {"name"=>"folder2", "file"=> [{"name"=>"file1", "content"=>"\n "}, {"name"=>"file2", "content"=>"\n "}]}]} You can customize the printing to suit your taste. There are different options to xml-simple that let you control the array/hash structure that gets generated. ----- Brian Marick, independent consultant Mostly on agile methods with a testing slant www.exampler.com, www.exampler.com/blog, twitter.com/marick ----- Brian Marick, independent consultant Mostly on agile methods with a testing slant www.exampler.com, www.exampler.com/blog, twitter.com/marick