Location: PHPKode > scripts > XParser > example.php
<?php
header("Content-Type: text/plain; charset=UTF-8");

require_once "classes/xparser_php530.class.php";

$p = new XParser("sample.xml");
$books = $p("book");
foreach ($books as $book) {
	echo "Id:\t".$book->id."\n";
	echo "Title:\t".$book("title")."\n";
	echo "Author:\t".$book("author")."\n";
	echo "Genre:\t".$book("genre")."\n";
	echo "Price:\t".$book("price")."\n";
	echo "Date:\t".$book("publish_date")."\n";
	echo "Description:\n".$book("description")."\n";
	echo "\n\n";
}

// get the first dom object
$obj = $books[0];
echo "Node Name: ".$obj->nodeName;
?>
Return current item: XParser