From: "NAKAMURA, Hiroshi" Date: 2006-07-31T22:43:15+09:00 Subject: Re: humanized Xml tree navigation -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, chiaro scuro wrote: > Does anybody know of a library that allows to go through an xml tree as if > it were made of normal objects? > What I need to do is to be able to traverse an xml document as in: > > * people.each_person {...} > * people.person[2].name > * people.person.name #takes the first person > * people.person.size 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")) => #, #, #]> 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. Regards, // NaHi -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2.1 (Cygwin) iQEVAwUBRM4IxB9L2jg5EEGlAQLiHAf8DvhvC/LwgsAZNOZYDUhJQ9SdCMrhHWq2 WlAW/SyIJXhEvXWv+Rl/Z148xTWutghiu/GzYw6yZ/hUiEaGtXNA5DJkdcAYvmz+ g+FDDjtuCWJ07NEk+l3cQE4bztEq0q+6uHUQApl98EJhbpWXe35ZvOOjnrUwo0uF 0xHs9btBtqix9j0I6iJeqB4uXtLUSs2fc+H5uzUBGAEF0gQ7T1jR3ewQ7HsdBtWw 4eoHgyQ3WcC4qmJir0t8VHlRSox91LzX+C/cWBLAZHfYX00wKl7U9XtmUanMl2tX IU15m74iiSLASwNdBUY575Tv4vbLykXvgEqReXXDQPGgqhnLgVd1RQ== =SYJM -----END PGP SIGNATURE-----