2ge has asked for the wisdom of the Perl Monks concerning the following question:
Hi monks!
I know how to validate XML, but still error massages appears on STDOUT, anyone knows how to avoid them ? my code looks:
thanks a lot!
I know how to validate XML, but still error massages appears on STDOUT, anyone knows how to avoid them ? my code looks:
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
thanks a lot!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: XML validating (no DTD)
by ikegami (Patriarch) on Sep 02, 2004 at 15:57 UTC | |
Re: XML validating (no DTD)
by Plankton (Vicar) on Sep 02, 2004 at 15:48 UTC | |
Re: XML validating (no DTD)
by iburrell (Chaplain) on Sep 02, 2004 at 16:47 UTC | |
by 2ge (Scribe) on Sep 02, 2004 at 21:33 UTC |
Back to
Seekers of Perl Wisdom