xref: /php-src/ext/dom/tests/modern/spec/bug47847.phpt (revision 6e7adb3c)
1--TEST--
2Bug #47847 (importNode loses the namespace of an XML element)
3--EXTENSIONS--
4dom
5--FILE--
6<?php
7$fromdom = Dom\XMLDocument::createFromString(<<<XML
8<?xml version="1.0"?>
9<ns:container xmlns:ns="http://php.net">
10<ns:inner xmlns="http://php.net">
11<ns:WATCH-MY-NAMESPACE xmlns=""/>
12</ns:inner>
13</ns:container>
14XML);
15
16$aDOM = Dom\XMLDocument::createEmpty();
17$imported = $aDOM->importNode($fromdom->documentElement->firstElementChild, true);
18$aDOM->appendChild($imported);
19
20echo $aDOM->saveXml(), "\n";
21
22var_dump($aDOM->documentElement->firstElementChild->prefix);
23?>
24--EXPECT--
25<?xml version="1.0" encoding="UTF-8"?>
26<ns:inner xmlns:ns="http://php.net" xmlns="http://php.net">
27<WATCH-MY-NAMESPACE/>
28</ns:inner>
29string(2) "ns"
30