1<?php
2$reader = new XMLReader();
3$reader->open('xmlreader.xml');
4while ($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?>
21