|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47849 Non-deep import loses the namespace
Submitted: 2009-03-31 11:48 UTC Modified: 2009-04-07 15:36 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
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:
 [2009-03-31 11:48 UTC] robin2008 at altruists dot org
I was expecting importNode to respect namespace

Reproduce code:
// PHP 5.2.* namespace bug - importNode doesn't preserve the namespace if deep=0. 

$aDOM= new DOMDocument();
$aDOM->appendChild($aDOM->createElementNS(' ','f2f:a'));
echo 'DOM to add into is '.$aDOM->saveXML().chr(13);

$fromdom= DOMDocument::loadXML('<data xmlns=" "/>');
echo 'Dom to import from is'.$fromdom->saveXML().chr(13);

$data= $fromdom->firstChild;

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.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-04-07 15:36 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2015 The PHP Group
All rights reserved.
Last updated: Wed Dec 02 03:01:32 2015 UTC