1<?php
2$indent = 5; /* Number of spaces to indent per level */
3
4$xml = new XMLReader();
5$xml->open("dtdexample.xml");
6$xml->setParserProperty(XMLREADER::LOADDTD, TRUE);
7$xml->setParserProperty(XMLREADER::VALIDATE, TRUE);
8while($xml->read()) {
9	/* Print node name indenting it based on depth and $indent var */
10	print str_repeat(" ", $xml->depth * $indent).$xml->name."\n";
11	if ($xml->hasAttributes) {
12		$attCount = $xml->attributeCount;
13		print str_repeat(" ", $xml->depth * $indent)." Number of Attributes: ".$xml->attributeCount."\n";
14	}
15}
16print "\n\nValid:\n";
17var_dump($xml->isValid());
18?>
19