xmlreader_file.php 590 B

1234567891011121314151617181920
  1. <?php
  2. $reader = new XMLReader();
  3. $reader->open('xmlreader.xml');
  4. while ($reader->read()) {
  5. if ($reader->nodeType != XMLREADER::END_ELEMENT) {
  6. print "Node Name: ".$reader->name."\n";
  7. print "Node Value: ".$reader->value."\n";
  8. print "Node Depth: ".$reader->depth."\n";
  9. if ($reader->nodeType==XMLREADER::ELEMENT && $reader->hasAttributes) {
  10. $attr = $reader->moveToFirstAttribute();
  11. while ($attr) {
  12. print " Attribute Name: ".$reader->name."\n";
  13. print " Attribute Value: ".$reader->value."\n";
  14. $attr = $reader->moveToNextAttribute();
  15. }
  16. }
  17. print "\n";
  18. }
  19. }
  20. ?>