PHP Magazine has a link to a new uk.builder.com article today about using PHP to run XPath queries on your XML documents.
XPath is a language that allows you to address parts of an XML document, making XSLT transformations practically necessary. It also makes it an invaluable tool for managing XML data in applications such as Web applications.
Microsoft provides XPath functionality through the selectSingleNode() and selectNodes() methods on DOM nodes and documents. However, PHP uses functions that provide XPath functionality through contexts. In the following example, I'll show sample XML data and PHP code to grab different parts of the XML document. I'll also explain how the PHP code works.
They give a simple example of how to combine the DOM XML functionality and a few of the XPath functions included to grab the data needed (such as xpath_eval). Their code listing gives all of the details on how to set up the document, parse it with the DOM XML engine, and grab the contents needed with a few simple function calls.




