Skip Menu |
 
rt.cpan.org will be shut down on March 1st, 2021.

This queue is for tickets about the XML-Simple CPAN distribution.

Report information
The Basics
Id: 50861
Status: rejected
Priority: 0/
Queue: XML-Simple

People
Owner: Nobody in particular
Requestors: aylazhang [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



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>
Download (untitled) / with headers
text/plain 1.6k
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
Download (untitled) / with headers
text/plain 340b
The behaviour you describe is exactly how XML::Simple is supposed to work. If you don't want the array folding feature then turn it off with the KeyAttr option. If you try to use XML::Simple without specifying any options then you will experience problems. This article may be helpful: http://www.perlmonks.org/index.pl?node_id=218480


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.