programming-examples/perl/XML/Using XML_Parser to parse xml file.pl
2019-11-15 12:59:38 +01:00

13 lines
349 B
Perl

use XML::Parser;
my $xmlfile = "yourXML.xml";
my $parser = XML::Parser->new( ErrorContext => 2 );
eval { $parser->parsefile( $xmlfile ); };
if( $@ ) {
$@ =~ s/at \/.*?$//s; # remove module line number
print STDERR "\nERROR in '$file':\n$@\n";
} else {
print STDERR "'$file' is well-formed\n";
}