use XML::Checker::Parser; my %expat_options = (KeepCDATA => 1, Handlers => [ Unparsed => \&my_Unparsed_handler ]); my $parser = new XML::Checker::Parser (%expat_options); eval { local $XML::Checker::FAIL = \&my_fail; $parser->parsefile ("fail.xml"); }; if ($@) { print $@; } else{ print "xml has been validated"; } sub my_fail { my $code = shift; die XML::Checker::error_string ($code, @_) if $code < 200; XML::Checker::print_error ($code, @_); } #### ]> "something should not be here"