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> |
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