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: 24154
Status: rejected
Priority: 0/
Queue: XML-Simple

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

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



Subject: Attribute name changes parsed data structure
Date: Sat, 30 Dec 2006 16:51:12 +0100
To: bug-XML-Simple [...] rt.cpan.org
From: Marco Del Percio <marco.delpercio [...] gmail.com>
Download (untitled) / with headers
text/plain 1.2k
Hi I ran into this and I think it is a bug. Try to parse with Xml::Simple this simple file (test1.xml): <?xml version="1.0" ?> <root> <page nome="one" attribute="C"> <bla att="1"/> </page> <page nome="two" feature="H"> <bla att="3"/> </page> </root> I used this very simple test application: use XML::Simple; use Data::Dumper; my $xml = new XML::Simple(); my $ref = $xml->XMLin("test1.xml"); print Dumper($ref); If you run this you'll get (as everyone expect) that $ref->{page} is an array. Now try this little change to the xml file and use the same testing application: <?xml version="1.0" ?> <root> <page name="one" attribute="C"> <bla att="1"/> </page> <page name="two" feature="H"> <bla att="3"/> </page> </root> Now the attribute is called "name" and not as in Italian (my language) "nome". If you parse the file and you observe the Dump now you'll see that $ref->{page} is no longer an array... it is an hash like this $ref->{page}->{one} $ref->{page}->{two} Nowhere in the dump of the structure appear the "name" attribute string. Is this a problem of xml? I don't think the attribute "name" is a special reserved attribute name in xml. Greetings Marco Del Percio from Italy
Download (untitled) / with headers
text/plain 257b
The behaviour you are seeing is normal given the default value of the KeyAttr option. If you don't want this behaviour you can disable array folding with KeyAttr => { }. You might find this article useful: 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.