xref: /PHP-8.4/ext/xmlreader/tests/expand.phpt (revision 74859783)
1--TEST--
2XMLReader: Expand into existing DOM documet
3--EXTENSIONS--
4xmlreader
5dom
6--SKIPIF--
7<?php $reader = new XMLReader();
8if (!method_exists($reader, 'expand')) print "skip";
9?>
10--FILE--
11<?php
12
13$basexml = '<?xml version="1.0" encoding="UTF-8"?>
14<books><book>base book</book></books>';
15
16$xmlstring = '<?xml version="1.0" encoding="UTF-8"?>
17<books><book>new book</book></books>';
18
19$dom = new DOMDocument();
20$dom->loadXML($basexml);
21
22$reader = new XMLReader();
23$reader->XML($xmlstring);
24while ($reader->read()) {
25    if ($reader->localName == "book") {
26        $node = $reader->expand($dom);
27        if ($node->ownerDocument) {
28            echo $node->ownerDocument->documentElement->firstChild->textContent . "\n";
29        }
30        break;
31    }
32}
33$reader->close();
34?>
35--EXPECT--
36base book
37