summaryrefslogtreecommitdiff
path: root/ext/xmlreader/tests/expand.phpt
blob: 3d9b0a53c37865e32bde3ad885afc9461eb2c912 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
--TEST--
XMLReader: Expand into existing DOM documet
--SKIPIF--
<?php if (!extension_loaded("xmlreader")) print "skip";
if (!extension_loaded("dom")) print "skip DOM extension required";
$reader = new XMLReader();
if (!method_exists($reader, 'expand')) print "skip";
?>
--FILE--
<?php

$basexml = '<?xml version="1.0" encoding="UTF-8"?>
<books><book>base book</book></books>';

$xmlstring = '<?xml version="1.0" encoding="UTF-8"?>
<books><book>new book</book></books>';

$dom = new DOMDocument();
$dom->loadXML($basexml);

$reader = new XMLReader();
$reader->XML($xmlstring);
while ($reader->read()) {
    if ($reader->localName == "book") {
        $node = $reader->expand($dom);
        if ($node->ownerDocument) {
            echo $node->ownerDocument->documentElement->firstChild->textContent . "\n";
        }
        break;
    }
}
$reader->close();
?>
===DONE===
--EXPECT--
base book
===DONE===