From: Bob Hutchison Date: 2006-08-01T21:50:21+09:00 Subject: Re: humanized Xml tree navigation Hi, On Jul 31, 2006, at 9:43 AM, NAKAMURA, Hiroshi wrote: > 0% cat people.xml > > > name1 > 1 > > > name2 > 2 > > > name3 > 3 > > > 0% irb > irb(main):001:0> require 'xsd/mapping' > => true > irb(main):002:0> people = XSD::Mapping.xml2obj(File.read > ("people.xml")) > => # {}person=[# size="1">, > #, > #]> > irb(main):003:0> people.person.each { |person| p person } > # > # > # > => [#, > #, > #] > irb(main):004:0> people.person[2].name > => "name3" > irb(main):005:0> people.person.name > NoMethodError: undefined method `name' for # > from (irb):5 > irb(main):006:0> > > Almost. > Nice! I didn't know about this. Loses child ordering though, mixed content, and the root element? Both of the following lines: puts XSD::Mapping.obj2xml(XSD::Mapping.xml2obj("

")) puts XSD::Mapping.obj2xml(XSD::Mapping.xml2obj("

12345

")) give the same output: Cheers, Bob ---- Bob Hutchison -- blogs at Recursive Design Inc. -- Raconteur -- xampl for Ruby --