note 20057 deleted from function.xptr-eval by didou
| From: | didou@php.net | Date: | Fri, 17 Jun 2005 19:01:35 +0000 |
| Subject: | note 20057 deleted from function.xptr-eval by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-90598@lists.php.net to get a copy of this message | ||
Note Submitter: sbarnum@pointsystems dot com
----
Found a must-see tutorial for generating xPath expressions:
http://www.zvon.org/xxl/XPathTutorial/General/examples.html
For newbies (like me) out there, here's how you use xpath on an xml file:
$expression = "//SomeElement/Child";
$doc = xmldocfile('myfile.xml');
$xpc = xpath_new_context($doc);
$result = xpath_eval($xpc, $expression);
$found = $result->nodeset;
echo "<pre>";
echo "xpath found " . count($found) . "match(es):\n";
foreach($found AS $node)
xmlnode2html($node);
echo "</pre>";
----------------------------------
the $result is an object containing an array of nodes matching the xpath expression.