xpath()

It runs an XPath query on XML data

  • XPath is a major element in the XSLT standard.
  • XPath can be used to navigate through elements and attributes in an XML document.
  • XPath stands for XML Path Language
  • XPath uses “path like” syntax to identify and navigate nodes in an XML document
  • XPath contains over 200 built-in functions
  • XPath is a major element in the XSLT standard
  • XPath is a W3C recommendation

Example

<?php
$xml = simplexml_load_file(“test.xml”);
$xml->registerXPathNamespace(“msg”,”http://www.phpcodez.com”);
$result = $xml->xpath(“msg:web”);
?>

XML

<?xml version=”1.0″ encoding=”ISO-8859-1″?>
<web>
<server ver=”5″>Apache</server>
<lan>PHP</lan>
<client>Javascript</client>
</web>

Share