rubric has asked for the wisdom of the Perl Monks concerning the following question:
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 ("valid.xml"); }; if ($@) { print "Either XML::Parser (expat) threw an exception or my_fail() +died."; } # 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, @_); } sub my_Unparsed_handler { print "!"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: XML::Checker::Parser
by mirod (Canon) on Nov 22, 2002 at 19:01 UTC | |
by rubric (Initiate) on Nov 25, 2002 at 10:00 UTC | |
by mirod (Canon) on Nov 25, 2002 at 10:06 UTC | |
by rubric (Initiate) on Nov 25, 2002 at 10:42 UTC | |
|
Re: XML::Checker::Parser
by vek (Prior) on Nov 22, 2002 at 18:57 UTC | |
by rubric (Initiate) on Nov 25, 2002 at 10:07 UTC | |
by mirod (Canon) on Nov 25, 2002 at 12:01 UTC |