Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Dear Perlmonks,
I would like the below script to outpout all XML errors and not stop at the first instance only:
How could this be achieved? Thanks
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
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: XML::Parser XML validation
by choroba (Cardinal) on Jan 05, 2013 at 11:32 UTC | |
by Anonymous Monk on Jan 05, 2013 at 11:35 UTC | |
by CountZero (Bishop) on Jan 05, 2013 at 13:47 UTC | |
Re: XML::Parser XML validation
by Anonymous Monk on Jan 05, 2013 at 12:43 UTC | |
Re: XML::Parser XML validation
by karlgoethebier (Abbot) on Jan 05, 2013 at 17:25 UTC |
Back to
Seekers of Perl Wisdom