From: niklas | brueckenschlaeger Date: 2010-12-06T21:06:09+09:00 Subject: Re: Traverse YAML node tree with non-unique values --=-oM2SqH/F+AHBInMdiTIs Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Actually that document *is* invalid. The YAML spec [1] says about mappings: The content of a mapping node is an unordered set of key: value node pairs, with the restriction that each of the keys is unique. [1] - http://yaml.org/spec/1.2/spec.html#id2764044 On Mon, 2010-12-06 at 19:43 +0900, Martin C. wrote: > I have a YAML document which I believe is valid (at least it would be > representable in XML): >=20 > purchase_order: > date: 10/12/2010 > vendor: 12345 > item: > product: Tomatoes > quantity: 5 > item: > product: Eggs > quantity: 2 >=20 > The problem is that using YAML.read on this produces a Hash in which > only one item occurs because (naturally) it has to be unique. >=20 > How can one traverse the nodes in a YAML document like this? >=20 --=-oM2SqH/F+AHBInMdiTIs Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iQIcBAABAgAGBQJM/NGrAAoJEIQdQGZOjo822MUP/jnRE1BeZtvVDc4fiFk1Dk9v jvRhjLGFmlvXL1hQaCdD/c2Ld9wVW1F4KduHSC428+Kx6Y4emsexenqQ/H7GIrV4 TaLOcZx0HXews9Lsy6ueUzXmVRhy7BzXPqd7rX/UGASnnuEuc63wnG2W+w8m3CNI sqQZzmk4ePYTqpBOkvgu4CR/KHYmxGu/OM10eVwvpAsJn1tzszPrmK0mgKdDMFMj +mH2XRwqx2YhU79tP+dsz4RJSH6uP2lPlpVK0V4Zb8FqtVbPM2W6LytXRjYbWnT4 Aa/W9HYXalCr0z/FoV4Gu3gmqW51na4wx/xHPV9tdKJrpJFkXJMDMImwowX0hkpF 6QlITQnsjFw3zvKVQSfUU37fxryktH4oweRhaQv6PAo0fnMpem5hPe3RBI/DEIcg NTggHxDSG+DhTamwuRAR4AY0/JwDZEABFYay7Q30ks4sx1g286ukfRnELgg59gSu VZsLO0FVTuhUEgu6FyNSf1ZE9idXhEeXGGntjtbrQnkjAR0Wq1mc55eCwO+Q0rv0 CG9ke9C+ScnqucFMh84/ZU3EQ5jbDqGC7JlR5RJBSYAPyWLUu3tVDRs189LXbhhw bjZq5eZXQkgzmiIopRImmHZ7C5XHV6GWAHsEekt9keEZzGzRK31y+OtLS7P9UqGb bdRCfFPnKrJIxy5IvvK9 =nBu2 -----END PGP SIGNATURE----- --=-oM2SqH/F+AHBInMdiTIs--