Subject: | A seldom xml node issues |
Date: | Tue, 27 Oct 2009 17:26:13 +0800 |
To: | bug-XML-Simple [...] rt.cpan.org |
From: | zhang yan <aylazhang [...] gmail.com> |
Hello,
When i use the XML::Simple v2.16, get some problem as following.
my $body = '<?xml version="1.0" ?>
<opt>
<details>
<row>
<pid>111</pid>
<name>Test One</name>
</row>
<row>
<pid>222</pid>
<name>Test Two</name>
</row>
</details>
</opt>
';
my $xml = XML::Simple->new();
my $xhash = eval { $xml->XMLin($body, ForceArray => [ 'row' ]) };
#my $xhash = eval { $xml->XMLin($body) };
print Dumper($xhash);
The result is reasonless.
$VAR1 = {
'details' => {
'row' => {
'Test One' => {
'pid' => '111'
},
'Test Two' => {
'pid' => '222'
}
}
}
};
if substitut the <name> to any other issuse but not "name","key" or
"id".(Or i add the Keyadd => [] to new() method)
the result will be ideal.
$VAR1 = {
'details' => {
'row' => [
{
't_name' => 'Test One',
'pid' => '111'
},
{
't_name' => 'Test Two',
'pid' => '222'
}
]
}
};
pls check it .Thanks in advance.
Regards,
Ayla