Skip Menu |
 

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

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

People
Owner: Nobody in particular
Requestors: jesse.cook [...] eads-na-security.com
Cc:
AdminCc:

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



Subject: bug
Date: Sat, 18 Jul 2009 17:03:23 -0500
To: <bug-XML-Simple [...] rt.cpan.org>
From: "Jesse Cook" <jesse.cook [...] eads-na-security.com>
Download (untitled) / with headers
text/plain 3.2k
I've noticed a rather bizarre bug. Using 'name' as an element name with certain xml structures results in an incorrect data structure being formed. I provided a sample program and XML files with output to illustrate the bug. Sample Code: #!/usr/bin/perl -w use strict; use XML::Simple; use Data::Dumper; my $xml = new XML::Simple; my $data = $xml->XMLin("config.xml"); print Dumper($data); Working XML File: <?xml version="1.0" encoding="ISO-8859-1"?> <config> <install_disks> <total>1</total> <disk> <disk_label>Install_Disk_1</disk_label> <vm_install_isos> <total>1</total> <iso> <iso_name>a.iso</iso_name> </iso> <iso> <iso_name>b.iso</iso_name> </iso> </vm_install_isos> </disk> </install_disks> </config> Working Output: $VAR1 = { 'install_disks' => { 'disk' => { 'vm_install_isos' => { 'iso' => [ { 'iso_name' => 'a.iso' }, { 'iso_name' => 'b.iso' } ], 'total' => '1' }, 'disk_label' => 'Install_Disk_1' }, 'total' => '1' } }; XML file that results in incorrect data structure: <?xml version="1.0" encoding="ISO-8859-1"?> <config> <install_disks> <total>1</total> <disk> <disk_label>Install_Disk_1</disk_label> <vm_install_isos> <total>1</total> <iso> <name>a.iso</name> </iso> <iso> <name>b.iso</name> </iso> </vm_install_isos> </disk> </install_disks> </config> Output showing incorrect data structure: $VAR1 = { 'install_disks' => { 'disk' => { 'vm_install_isos' => { 'iso' => { 'a.iso' => {}, 'b.iso' => {} }, 'total' => '1' }, 'disk_label' => 'Install_Disk_1' }, 'total' => '1' } }; Sincerely, Jesse Cook
Download (untitled) / with headers
text/html 10.6k
Download (untitled) / with headers
text/plain 426b
The behaviour you describe is consistent with the default value of the KeyAttr option. If you want different behaviour then change the value of that option: http://search.cpan.org/dist/XML-Simple/lib/XML/Simple.pm#OPTIONS It is almost always a bug in your code to call XMLin() without specifying any options. Have a look at this article for more info: http://www.perlmonks.org/index.pl?node_id=218480 Regards Grant
Subject: [rt.cpan.org #48000] bug
Date: Sun, 19 Jul 2009 09:28:52 -0500
To: <bug-XML-Simple [...] rt.cpan.org>
From: "Jesse Cook" <jesse.cook [...] eads-na-security.com>
Download (untitled) / with headers
text/plain 680b
Awesome, thx. I fail for not doing my homework. Sorry for the false alarm. On Jul 18, 2009, at 7:14 PM, "Grant McLean via RT" <bug-XML-Simple@rt.cpan.org Show quoted text
> wrote:
Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=48000 > > > The behaviour you describe is consistent with the default value of the > KeyAttr option. If you want different behaviour then change the value > of that option: > > http://search.cpan.org/dist/XML-Simple/lib/XML/Simple.pm#OPTIONS > > It is almost always a bug in your code to call XMLin() without > specifying any options. Have a look at this article for more info: > > http://www.perlmonks.org/index.pl?node_id=218480 > > Regards > Grant > >
Please don't reply to this email - it just reopens the ticket :-)


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.