Non-deep import loses the namespace
| Bug #47849 | Non-deep import loses the namespace | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Submitted: | 2009-03-31 11:48 UTC | Modified: | 2009-04-07 15:36 UTC |
|
||||||||||
| From: | robin2008 at altruists dot org | Assigned: | ||||||||||||
| Status: | Closed | Package: | DOM XML related | |||||||||||
| PHP Version: | 5.2.9 | OS: | Ubuntu | |||||||||||
| Private report: | No | CVE-ID: | None | |||||||||||
[2009-03-31 11:48 UTC] robin2008 at altruists dot org
Description:
------------
I was expecting importNode to respect namespace
Reproduce code:
---------------
<?php
// PHP 5.2.* namespace bug - importNode doesn't preserve the namespace if deep=0.
$aDOM= new DOMDocument();
$aDOM->appendChild($aDOM->createElementNS(' http://friend2friend.net/ ','f2f:a'));
echo 'DOM to add into is '.$aDOM->saveXML().chr(13);
$fromdom= DOMDocument::loadXML('<data xmlns=" http://altruists.org "/>');
echo 'Dom to import from is'.$fromdom->saveXML().chr(13);
$data= $fromdom->firstChild;
$aDOM->documentElement->appendChild($aDOM->importNode($data));
echo 'Result is '.$aDOM->saveXML();
?>
Expected result:
----------------
The manual says "This function returns a copy of the node to import and associates it with the current document. " so I was expecting it to preserve the namespace
Actual result:
--------------
The namespace gets lost.
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2009-04-07 15:36 UTC] rrichards@php.net