data.xml is: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; }
OUTPUT is:<?xml version="1.0" encoding="utf-8"?> <series> <article> <url>http://builder.com.com/article.jhtml?id=..htm</url> <title>Remedial XML for programmers: Basic syntax</title> <summary>In this first installment in...</summary> </article> </series>
I dont't want to see error messages.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
In reply to XML validating (no DTD) by 2ge
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |