php.net |  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
Votes:1
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: 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

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-04-07 15:36 UTC] rrichards@php.net
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
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 06:01:30 2024 UTC