xpath.php : xpath « XML « PHP






xpath.php

 
<?php
   $xml = simplexml_load_file("books.xml");
   $authors = $xml->xpath("/library/book/author");
   foreach($authors AS $author) {
      echo "$author<br />";
   }
?>
  
  








Related examples in the same category

1.Combine it with an XPath search
2.Using XPath and DOM
3.Using XPath and SimpleXML in a basic example
4.Using XPath with DOM in a basic example
5.Using XPath with SimpleXML in a more complicated example
6.XPath DOM Query
7.XPath can be used to filter your results according to any values
8.Searching and Filtering with XPath