php.net |  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 Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: chaced at gmail dot com
New email:
PHP Version: OS:

 

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




Test script:
---------------
<?php
function test($xml) {
	$dom = new DomDocument();
	$dom->loadXML($xml);
	$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 
xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.001.03"/></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>


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


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-12-02 16:29 UTC] mike@php.net
-Status: Open +Status: Feedback
 [2013-12-02 16:29 UTC] mike@php.net
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-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 14:01:32 2024 UTC