|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47847 importNode loses the namespace of an XML element.
Submitted: 2009-03-31 11:20 UTC Modified: -
Avg. Score:4.4 ± 0.7
Reproduced:12 of 12 (100.0%)
Same Version:6 (50.0%)
Same OS:6 (50.0%)
From: robin2008 at altruists dot org Assigned:
Status: Open Package: DOM XML related
PHP Version: 5.2.9 OS: Ubuntu
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2009-03-31 11:20 UTC] robin2008 at altruists dot org
ImportNode don't treat namespace properly

Reproduce code:
// PHP 5.2.* namespace bug - A namespaced node loses its namespace on import if 
//		(i)  It has @xmlns=""
//		(ii) A namespaceURI of its parent's @xmlns

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

$fromdom= DOMDocument::loadXML('<?xml version="1.0"?><f2f:data xmlns:f2f=" "><f2f:servicereq xmlns=" ">
<f2f:WATCH-MY-NAMESPACE xmlns=""/></f2f:servicereq></f2f:data>
echo 'Dom to import from is'.$fromdom->saveXML().chr(13);

$imported= $aDOM->importNode($fromdom->firstChild->firstChild, 1);
echo 'Result is '.$aDOM->saveXML();

Expected result:
Namespace should be preserved

Actual result:
Namespace gets lost


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2023-04-22 05:02 UTC] hunthealth8 at gmail dot com
Healthhunt are sharing latest news about Disease Management, Lifestyle & Wellness, Men's  Mental Health etc. More info to visit:(
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Mon May 29 12:03:44 2023 UTC