(1) Change <id> to anything else, or
(2) Add an empty section to the bottom of my xml file.
Could this be a bug in 5.10.1 ActivePerl or my test xml script is no good?
Expand|Select|Wrap|Line Numbers
- use strict;
- use warnings;
- use XML::Simple;
- use XML::Parser;
- use Data::Dumper;
- my @failxml = (
- "<tests>\n",
- "<test>\n",
- "<id>1</id>\n",
- "</test>\n",
- "<test>\n",
- "<id>2</id>\n",
- "</test>\n",
- "</tests>\n"
- );
- my @passxml = (
- "<tests>\n",
- "<test>\n",
- "<id>1</id>\n",
- "</test>\n",
- "<test>\n",
- "<id>2</id>\n",
- "</test>\n",
- "<test>\n",
- "</test>\n",
- "</tests>\n"
- );
- open (OUT, ">test.xml");
- print OUT @failxml;
- close (OUT);
- my $testlist = XMLin('test.xml');
- print Dumper($testlist);
- foreach my $test (@{$testlist->{test}}) {
- print $test->{id} ;
- print " ..worked..\n";
- }
thanks for looking at my newbie junk code.
====results follow====
C:\perl>test.pl
$VAR1 = {
'test' => {
'1' => {},
'2' => {}
}
};
Not an ARRAY reference at C:\perl\test.pl line 39.
====i changed fail to pass and repeated the test====
C:\perl>test.pl
$VAR1 = {
'test' => [
{
'id' => '1'
},
{
'id' => '2'
},
{}
]
};
1 ..worked..
2 ..worked..
Use of uninitialized value in print at C:\perl\test.pl line 40.
..worked..
C:\perl>