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