Permalink
Browse files

official example, not much yet, but the idea is there

git-svn-id: http://svn.php.net/repository/pear/packages/XML_XPath/trunk@84890 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
1 parent e999901 commit 7fdf03ced9286eb8c7f7b558e68ee5a5e66434a7 Daniel Allen committed Jun 7, 2002
Showing with 27 additions and 0 deletions.
  1. +27 −0 docs/XML_XPath_example.php
View
27 docs/XML_XPath_example.php
@@ -0,0 +1,27 @@
+<?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";
+?>

0 comments on commit 7fdf03c

Please sign in to comment.