From: "Kroeger, Simon (ext)" Date: 2006-05-08T18:32:41+09:00 Subject: Re: new to Ruby and XML Hi Hunter, quick and dirty: Hash[*xml.scan(%r{>([^>]*)}).flatten] returns {"12"=>"AAF", "7"=>"AAE", "13"=>"AAG", "8"=>"AAA", "9"=>"ISA", "1"=>"AAA", "2"=>"AAB", "4"=>"AAC", "5"=>"AAD"} cheers Simon > -----Original Message----- > From: list-bounce@example.com > [mailto:list-bounce@example.com] On Behalf Of Hunter Walker > Sent: Monday, May 08, 2006 8:31 AM > To: ruby-talk ML > Subject: new to Ruby and XML > > Hi all, > > I have an API call to another database app that returns the XML below: > > 9 id='8'>ISA id='3'>8 > AAA id='3'>1 AAA > > 2 AAB > 4 AAC > 5 id='8'>AAD id='3'>7 > AAE id='3'>12 AAF > 13 AAG > > > I'd like to loop through each of these records and create a > hash. The > first value of each record being the key and the second being > the value > in the hash. > > Any ideas? Thank you for helping a noob! > > -Hunter > > -- > Posted via http://www.ruby-forum.com/. > >