Back to index

php5  5.3.10
xmlreader_relaxNG.php
Go to the documentation of this file.
00001 <?php
00002 $indent = 5; /* Number of spaces to indent per level */
00003 
00004 $reader = new XMLReader();
00005 $reader->open('relaxNG.xml');
00006 /*
00007 Example setting relaxNG using string:
00008 $reader->setRelaxNGSchemaSource(file_get_contents('relaxNG.rng'));
00009 */
00010 if ($reader->setRelaxNGSchema('relaxNG.rng')) {
00011   while ($reader->read()) {
00012     /* Print node name indenting it based on depth and $indent var */
00013     print str_repeat(" ", $reader->depth * $indent).$reader->name."\n";
00014   }
00015 }
00016 
00017 print "\n";
00018 
00019 if (! $reader->isValid()) {
00020   print "Document is not valid\n";
00021 } else {
00022   print "Document is valid\n";
00023 }
00024 
00025 ?>