Back to index

php5  5.3.10
xmlreader_validatedtd.php
Go to the documentation of this file.
00001 <?php
00002 $indent = 5; /* Number of spaces to indent per level */
00003 
00004 $xml = new XMLReader();
00005 $xml->open("dtdexample.xml");
00006 $xml->setParserProperty(XMLREADER::LOADDTD, TRUE);
00007 $xml->setParserProperty(XMLREADER::VALIDATE, TRUE);
00008 while($xml->read()) {
00009        /* Print node name indenting it based on depth and $indent var */
00010        print str_repeat(" ", $xml->depth * $indent).$xml->name."\n";
00011        if ($xml->hasAttributes) {
00012               $attCount = $xml->attributeCount;
00013               print str_repeat(" ", $xml->depth * $indent)." Number of Attributes: ".$xml->attributeCount."\n";
00014        }
00015 }
00016 print "\n\nValid:\n";
00017 var_dump($xml->isValid());
00018 ?>