the result is :use XML::Simple; use Data::Dumper; my $xml = XML::Simple->new(); my $body = ' <all> <products> <item> <name>a</name> <price>1</price> <count>1</count> </item> <item> <name>b</name> <price>1</price> <count>1</count> </item> </products> </all>'; my $xhash = $xml->XMLin($body); print Dumper($xhash);
$VAR1 = {
'products' => {
'item' => {
'a' => {
'count' => '1',
'price' => '1'
},
'b' => {
'count' => '1',
'price' => '1'
}
}
}
};
I really don't want to this result.
I want to get all "item" info into a Array ref.
just like this:
how to carry out the task? Thanks in advance! BTW:i use the option "ForceArray => 1",the result also is not perfect . Pysome$VAR1 = { 'products' => { 'item' =>[ { 'name' => 'a', 'count' => '1', 'price' => '1' }, { 'name' => 'b', 'count' => '1', 'price' => '1' } ] } };
In reply to A puzzle for parsing XML with XML::Simple! by pysome
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |