Be gentle this is my first foray into XML::Simple ---
I'm getting the following error message and can't understand why I'm getting it: Invalid name in entity [Ln: 290, Col: 689]
I'm also unable to use a string as the argument to XMLin(). When I do the script just burns CPU
and never returns.
The XML file I'm trying to parse loads just fine into Firefox http://<url>/test.xml. The xml is simple but there's a lot of it.
How do I figure out if there's really bad data or make XMLin() not blow up when it doesn't like something? I'd really like to pass the string - how do I do that? Where am I going wrong?
The code is fairly simple as well-
#!/usr/bin/perl
#
# xmlgb.pl
#
use strict;
use XML::Simple;
my @logtopdirs=qw( /var/logs/3300 );
my @logdirs=qw( 109 110 111 112 );
my $gunzip='/usr/bin/gunzip -c';
my @files;
my $xmlref;
my $xmlstr;
my $xmlfil;
my $tstfile="/tmp/test.xml";
foreach my $td ( @logtopdirs ) {
if ( ! chdir($td) ) {
print "ERROR: Can't chdir to top dir " . $td . "\n";
next;
}
print "Working on top dir ->>" . $td . "\n";
foreach my $dir ( @logdirs ) {
if ( ! chdir($dir) ) {
print "ERROR: Can't chdir to log dir " . $dir . "\n";
next;
}
@files=glob("*.gz");
foreach my $f ( @files ) {
print $dir . "/" . $f . "\n";
if ( ! -f $f ) {
print "No file " . $f . "\n";
}
else {
if ( ! open(XML,"$gunzip $f | ") ) {
print "Failed to open stream for " . $f . "\n";
next;
}
my $xs = XML::Simple->new(KeyAttr=>[],ForceArray=>1,KeepRoot=>1);
$xmlstr="";
while ( <XML> ) { $xmlstr .= $_; }
open(TST,">$tstfile");
print TST $xmlstr;
close(TST);
print $xs . "\n";
$xmlref = $xs->XMLin($tstfile);
%$xmlref={};
}
}
chdir ( $td );
}
}
exit();