use strict; use XML::Checker::Parser; my $xml_file = 'data.xml'; my $xp = new XML::Checker::Parser ( Handlers => { } ); eval { $xp->parsefile($xml_file); local $XML::Checker::FAIL = \&my_fail; }; if ($@) { print "$xml_file failed validation!\n"; } else { print "$xml_file passed validation\n"; } sub my_fail { my $code = shift; die XML::Checker::error_message ($code, @_) if $code < 300; } ####
http://builder.com.com/article.jhtml?id=..htm Remedial XML for programmers: Basic syntax In this first installment in...
##
## XML::Checker ERROR-101: undefined ELEMENT [series] Context: line 2, column 0, byte 40 XML::Checker ERROR-101: undefined ELEMENT [article] Context: line 3, column 6, byte 56 XML::Checker ERROR-101: undefined ELEMENT [url] Context: line 4, column 13, byte 80 XML::Checker ERROR-101: undefined ELEMENT [title] Context: line 5, column 13, byte 167 XML::Checker ERROR-101: undefined ELEMENT [summary] Context: line 6, column 13, byte 239 data.xml passed validation