|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #64254 remove node and re-append, namespace is dropped.
Submitted: 2013-02-20 17:20 UTC Modified: 2014-12-30 10:41 UTC
From: chaced at gmail dot com Assigned:
Status: No Feedback Package: DOM XML related
PHP Version: 5.4.11 OS: Linux debian
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: chaced at gmail dot com
New email:
PHP Version: OS:


 [2013-02-20 17:20 UTC] chaced at gmail dot com
A node has a namespace, remove this node, stock node into an array, and add this 
node, the namespace is dropped.

Test script:
function test($xml) {
	$dom = new DomDocument();
	$node = $dom->documentElement;
	$nodes = array();
	foreach($node->childNodes as $n) if($n->nodeType==XML_ELEMENT_NODE) $nodes[]=$n;
	foreach($nodes as $n) $n->parentNode->removeChild($n);
	foreach($nodes as $n) $node->appendChild($n);
	echo $dom->saveXML();

test('<?xml version="1.0" encoding="UTF-8"?><test xmlns:any="urn:iso:std:iso:20022:tech:xsd:pain.001.001.03"><item /><item xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.001.03"/></test>');
test('<?xml version="1.0" encoding="UTF-8"?><test xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.001.03"><item /><item xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.001.03"/></test>');

Expected result:
<?xml version="1.0" encoding="UTF-8"?>
<test xmlns:any="urn:iso:std:iso:20022:tech:xsd:pain.001.001.03"><item/><item 
<?xml version="1.0" encoding="UTF-8"?>
<test xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.001.03"><item/><item 

Actual result:
<?xml version="1.0" encoding="UTF-8"?>
<test xmlns:any="urn:iso:std:iso:20022:tech:xsd:pain.001.001.03"><item/>
<?xml version="1.0" encoding="UTF-8"?>
<test xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.001.03"><item/><item/>


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-12-02 16:29 UTC]
-Status: Open +Status: Feedback
 [2013-12-02 16:29 UTC]
The namespaces equal, or do I miss anything?
 [2014-12-30 10:41 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Mon May 29 12:03:44 2023 UTC