I'm trying to parse a large XML file. I'm using Saxerator.
My hash has a kind of tree:
obj= {
"id"=>'1', "groups" =>{
"group" =>[
{"id"=>"2", "groups"=>{}},
{"id"=>"3", "groups"=>{}},
{"id"=>"4", "groups"=>{
"group"=>[
{"id"=>"5", "groups"=>{}},
{"id"=>"6", "groups"=>{}},
]}}
]}}
I don't know in advance the depth of the tree. I had a problem. I have no idea how convert it in array. Result should be like this:
[{"id"=> "1", "parent_id"=> "0"},
{"id"=> "2", "parent_id"=> "1"},
{"id"=> "3", "parent_id"=> "1"},
{"id"=> "4", "parent_id"=> "1"},
{"id"=> "5", "parent_id"=> "4"},
{"id"=> "6", "parent_id"=> "4"}]
Have any ideas?