xmlreader_relaxNG.php 577 B

12345678910111213141516171819202122232425
  1. <?php
  2. $indent = 5; /* Number of spaces to indent per level */
  3. $reader = new XMLReader();
  4. $reader->open('relaxNG.xml');
  5. /*
  6. Example setting relaxNG using string:
  7. $reader->setRelaxNGSchemaSource(file_get_contents('relaxNG.rng'));
  8. */
  9. if ($reader->setRelaxNGSchema('relaxNG.rng')) {
  10. while ($reader->read()) {
  11. /* Print node name indenting it based on depth and $indent var */
  12. print str_repeat(" ", $reader->depth * $indent).$reader->name."\n";
  13. }
  14. }
  15. print "\n";
  16. if (! $reader->isValid()) {
  17. print "Document is not valid\n";
  18. } else {
  19. print "Document is valid\n";
  20. }
  21. ?>