Skip to content

Commit 6ca41b7

Browse files
committed
Add DOMDocument::xinclude() test for liveness
1 parent 3e1eadf commit 6ca41b7

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
--TEST--
2+
DOMDocument::getElementsByTagName() liveness with DOMDocument::xinclude()
3+
--EXTENSIONS--
4+
dom
5+
--FILE--
6+
<?php
7+
8+
// Adapted from https://www.php.net/manual/en/domdocument.xinclude.php
9+
$xml = <<<EOD
10+
<?xml version="1.0" ?>
11+
<chapter xmlns:xi="http://www.w3.org/2001/XInclude">
12+
<p>Hello</p>
13+
<para>
14+
<xi:include href="book.xml">
15+
<xi:fallback>
16+
<p>xinclude: book.xml not found</p>
17+
</xi:fallback>
18+
</xi:include>
19+
</para>
20+
</chapter>
21+
EOD;
22+
23+
$dom = new DOMDocument;
24+
$dom->loadXML($xml);
25+
$elements = $dom->getElementsByTagName('p');
26+
var_dump($elements->item(0)->textContent);
27+
@$dom->xinclude();
28+
var_dump($elements->item(1)->textContent);
29+
echo $dom->saveXML();
30+
31+
?>
32+
--EXPECT--
33+
string(5) "Hello"
34+
string(28) "xinclude: book.xml not found"
35+
<?xml version="1.0"?>
36+
<chapter xmlns:xi="http://www.w3.org/2001/XInclude">
37+
<p>Hello</p>
38+
<para>
39+
40+
<p>xinclude: book.xml not found</p>
41+
42+
</para>
43+
</chapter>

0 commit comments

Comments
 (0)