#!/usr/bin/perl -w use XML::Checker::Parser; my $parser = new XML::Checker::Parser (); die "Can't create object" unless (ref $parser); eval { local $XML::Checker::FAIL = \&my_fail; $parser->parsefile ("/usr/local/pd/ADS/index.xml"); }; if ($@) { # Either XML::Parser (expat) threw an exception or my_fail() died. #... your error handling code here ... print "you suck!\ngo eat a bone!\n"; } # Throws an exception (with die) when an error is encountered, this # will stop the parsing process. # Don't die if a warning or info message is encountered, just print a message. sub my_fail { my $code = shift; die XML::Checker::error_string ($code, @_) if $code < 200; XML::Checker::print_error ($code, @_); }