Dear Perlmonks,
I would like the below script to outpout all XML errors and not stop at the first instance only:
#!/usr/bin/perl
use XML::Parser;
my $xmlfile = shift @ARGV; # the file to parse
# initialize parser object and parse the string
my $parser = XML::Parser->new( ErrorContext => 2 );
eval { $parser->parsefile( $xmlfile ); };
# report any error that stopped parsing, or announce success
if( $@ ) {
$@ =~ s/at \/.*?$//s; # remove module line number
print STDERR "\nERROR in '$xmlfile':\n$@\n";
} else {
print STDERR "'$xmlfile' is well-formed\n";
}
How could this be achieved? Thanks