This is an odd one. I have an XML file that I was parsing without
problems using XML::Simple. When we altered the file structure a bit, the script broke.
It seems what broke it was the (newly added) tag named <id>. To make
things even stranger, it seems to only break when multiple containers
have this <id> tag. If only one has it, the script doesn't break.
The following example illustrates the problem. It should print out the
index of the last <record> node (in this case "1") but instead it
gives an error. Remove or rename one of the pair of <id> tags and the script
runs fine.
Any ideas?
Thanks,
Doran...
ps. I'm running perl v5.6
#! /perl/bin/perl -w
use strict;
use XML::Simple;
my $file;
{
local $/='';
$file=<DATA>;
}
my $xml=XMLin("$file");
my $progress = $xml->{dbf}{progress}{record};
print $#$progress;
__END__
<?xml version="1.0" standalone="yes"?>
<escinfo>
<dbf>
<progress>
<record>
<title>11111</title>
<id>abcd</id>
</record>
<record>
<title>22222</title>
<id>efgh</id>
</record>
</progress>
</dbf>
</escinfo>
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.