1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Add XPath test with a context node

This commit is contained in:
Niels Dossche
2023-09-02 14:16:55 +02:00
parent 0d7ef87bf6
commit 07c688f224

View File

@@ -0,0 +1,31 @@
--TEST--
XPath: with a context node
--EXTENSIONS--
dom
--FILE--
<?php
$dom = new DOMDocument();
$dom->loadXML(<<<XML
<root>
<child>
<p>bar</p>
</child>
<child>
<p>foo1</p>
<p>foo2</p>
</child>
</root>
XML);
$xpath = new DOMXpath($dom);
foreach ($xpath->query("p", $dom->documentElement->firstElementChild->nextElementSibling) as $p) {
echo $p->textContent, "\n";
}
var_dump($xpath->evaluate("count(p)", $dom->documentElement->firstElementChild->nextElementSibling));
?>
--EXPECT--
foo1
foo2
float(2)