summaryrefslogtreecommitdiff
path: root/ext/xmlreader/examples/xmlreader_validatedtd.php
diff options
context:
space:
mode:
Diffstat (limited to 'ext/xmlreader/examples/xmlreader_validatedtd.php')
-rw-r--r--ext/xmlreader/examples/xmlreader_validatedtd.php18
1 files changed, 18 insertions, 0 deletions
diff --git a/ext/xmlreader/examples/xmlreader_validatedtd.php b/ext/xmlreader/examples/xmlreader_validatedtd.php
new file mode 100644
index 0000000..5173154
--- /dev/null
+++ b/ext/xmlreader/examples/xmlreader_validatedtd.php
@@ -0,0 +1,18 @@
+<?php
+$indent = 5; /* Number of spaces to indent per level */
+
+$xml = new XMLReader();
+$xml->open("dtdexample.xml");
+$xml->setParserProperty(XMLREADER_LOADDTD, TRUE);
+$xml->setParserProperty(XMLREADER_VALIDATE, TRUE);
+while($xml->read()) {
+ /* Print node name indenting it based on depth and $indent var */
+ print str_repeat(" ", $xml->depth * $indent).$xml->name."\n";
+ if ($xml->hasAttributes) {
+ $attCount = $xml->attributeCount;
+ print str_repeat(" ", $xml->depth * $indent)." Number of Attributes: ".$xml->attributeCount."\n";
+ }
+}
+print "\n\nValid:\n";
+var_dump($xml->isValid());
+?> \ No newline at end of file