Files
archived-presentations/slides/php5xml2/xmlread_valid1.php
2005-05-16 23:53:57 +00:00

13 lines
435 B
PHP

<?php
$reader = new XMLReader();
/* load xml document as a string */
$reader->XML(file_get_contents(dirname(__FILE__) . '/thedata.xml'));
/* tell the parser to perform syntax validation */
$reader->setParserProperty(XMLREADER_VALIDATE, TRUE);
// loop until end of document
// @ blocks the parser errors (missing DTD in this case)
while (@$reader->read());
echo "XML document is: " . ($reader->isValid() ? '' : ' not') . " valid.";
?>