Bug #64254 [Fbk->NoF]: remove node and re-append, namespace is dropped.
Edit report at https://bugs.php.net/bug.php?id=64254&edit=1
ID: 64254
Updated by: php-bugs@lists.php.net
Reported by: chaced at gmail dot com
Summary: remove node and re-append, namespace is dropped.
-Status: Feedback
+Status: No Feedback
Type: Bug
Package: DOM XML related
Operating System: Linux debian
PHP Version: 5.4.11
Private report: N
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2013-12-02 16:29:52] mike@php.net
The namespaces equal, or do I miss anything?
------------------------------------------------------------------------
[2013-02-20 17:20:24] 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>
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=64254&edit=1
Thread (3 messages)