We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0d7ef87 commit 07c688fCopy full SHA for 07c688f
ext/dom/tests/xpath_context_node.phpt
@@ -0,0 +1,31 @@
1
+--TEST--
2
+XPath: with a context node
3
+--EXTENSIONS--
4
+dom
5
+--FILE--
6
+<?php
7
+$dom = new DOMDocument();
8
+$dom->loadXML(<<<XML
9
+<root>
10
+ <child>
11
+ <p>bar</p>
12
+ </child>
13
14
+ <p>foo1</p>
15
+ <p>foo2</p>
16
17
+</root>
18
+XML);
19
+$xpath = new DOMXpath($dom);
20
+
21
+foreach ($xpath->query("p", $dom->documentElement->firstElementChild->nextElementSibling) as $p) {
22
+ echo $p->textContent, "\n";
23
+}
24
25
+var_dump($xpath->evaluate("count(p)", $dom->documentElement->firstElementChild->nextElementSibling));
26
27
+?>
28
+--EXPECT--
29
+foo1
30
+foo2
31
+float(2)
0 commit comments