xsl-list
[Top] [All Lists]

[xsl] Validate xml against dtd in php

2008-09-09 05:39:11
Hi.

I want to validate my xml against a dtd located on the disc. Even if I
try to validate xml I know are valid (I've tried to validate it against
the dtd in xmlspy aswell), the result always prints 'Not valid'. Anyone
who knows how I can do this? 

<?php

function validate($xmlstring) {
        $dtd = "mydtd.dtd";     
        $dom = new domDocument;
        $dom->loadXML($xmlstring);
        if (!$dom->validate($dtd))      
          print "Not valid\n";    
        else 
          print "Valid\n";
}

validate("<book><test>hello</test></book>");

?>

Thanks!

Kjellaug.

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>
  • [xsl] Validate xml against dtd in php, Kjellaug Johansen <=