Reputation: 11
I have a YAML document which I believe is valid (at least it would be representable in XML):
purchase_order:
date: 10/12/2010
vendor: 12345
item:
product: Tomatoes
quantity: 5
item:
product: Eggs
quantity: 2
The problem is that using YAML.read on this produces a Hash in Ruby in which only one purchase order item occurs because (naturally) it has to be unique.
How else can one traverse the nodes in a YAML document like this?
Upvotes: 1
Views: 489
Reputation: 36532
The problem is that is not correct YAML for describing an array of items.
That would be this:
purchase_order:
date: 10/12/2010
vendor: 12345
items:
- quantity: 5
product: Tomatoes
- quantity: 2
product: Eggs
So I don't think you will be able to parse it as YAML.
Perhaps parsing it as a text file with a YAML-like structure is the best solution.
Upvotes: 2