XPath DOM Query
<html> <head> <title>XPath DOM Query</title> </head> <body> <?php $dom = new DomDocument(); $dom -> load( "food.xml" ); $xp = new DomXPath( $dom ); $fruits = $xp -> query( "/food/fruit/item" ); foreach($fruits as $node) { echo( "<li>" . $node -> textContent . "</li>" ); } echo( "</ul>" ); ?> </body> </html>