Dear All,
Now ,i came across a puzzled problem ,pls help me.
my code
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);
the result is :
$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:
$VAR1 = {
'products' => {
'item' =>[
{
'name' => 'a',
'count' => '1',
'price' => '1'
},
{
'name' => 'b',
'count' => '1',
'price' => '1'
} ]
}
};
how to carry out the task? Thanks in advance!
BTW:i use the option "ForceArray => 1",the result also is not perfect .
Pysome