hello
i figured this out!
while i couldnt find anything about the validate or
get_last _error functions i did manage to get code to werk!
thanks matt!
here is a sample xml:
<?xml version="1.0"?>
<!DOCTYPE roots SYSTEM 'dtd.dtd'>
<roots>
<child1 attrib="3"></child1>
<child2></child2>
<child3/>
</roots>
the dtd:
<!ELEMENT roots (child1,child2,child3)>
<!ELEMENT child1 (#PCDATA)>
<!ATTLIST child1 attrib CDATA #REQUIRED>
<!ELEMENT child2 EMPTY>
<!ELEMENT child3 (#PCDATA)>
and the perl script:
#!/usr/bin/perl
use strict;
use XML::LibXML;
my $parser = XML::LibXML->new();
$parser->validation(1);
eval {print "xml is valid=".$parser->parse_file('xml.xml')->is_valid
+."\n"; };
if ($@) { print "dtd not valid: $@\n";}
else { print "dtd valid\n";}
hope this helps anyone else in the future
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.