in reply to Re: using XML::LIbXML to validate against a dtd and retrieve any errors therein
in thread using XML::LIbXML to validate against a dtd and retrieve any errors therein

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