Skip to content

Commit 07c688f

Browse files
committed
Add XPath test with a context node
1 parent 0d7ef87 commit 07c688f

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

ext/dom/tests/xpath_context_node.phpt

+31
Original file line numberDiff line numberDiff line change
@@ -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+
<child>
14+
<p>foo1</p>
15+
<p>foo2</p>
16+
</child>
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

Comments
 (0)