cvs: pear /XML_XPath/docs XML_XPath_example.php
| From: | Daniel Allen | Date: | Fri, 07 Jun 2002 00:14:21 +0000 |
| Subject: | cvs: pear /XML_XPath/docs XML_XPath_example.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-4459@lists.php.net to get a copy of this message | ||
dallen Thu Jun 6 20:14:21 2002 EDT
Added files:
/pear/XML_XPath/docs XML_XPath_example.php
Log:
official example, not much yet, but the idea is there
Index: pear/XML_XPath/docs/XML_XPath_example.php
+++ pear/XML_XPath/docs/XML_XPath_example.php
<?php
require_once '../XPath.php';
$xml = new XML_XPath();
$string = '<?xml version="1.0"?>
<doc foo="bar">
<child1>foo</child1>
hey
<foo>bar</foo>
<child2>foo</child2>
<foo>stuff</foo>
<report id="5">
<title>Summary</title>
</report>
</doc>';
$xml->load($string, 'string');
$children = $xml->childNodes();
echo '----------' . "\n";
echo 'Showing each child of <doc> (Please note blank nodes are skipped)' .
"\n";
while ($children->next()) {
echo 'Index: ' . $children->getIndex() . ' Name: ' .
$children->nodeName() . "\n";
}
echo '----------' . "\n";
$xml->evaluate('//report[@id = "5"]', true);
$xml->evaluate('title', true, true);
echo 'The report title is: ' . $xml->substringData() . "\n";
echo '----------' . "\n";
?>