|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2013-12-02 16:29 UTC] mike@php.net
-Status: Open
+Status: Feedback
[2013-12-02 16:29 UTC] mike@php.net
[2014-12-30 10:41 UTC] php-bugs at lists dot php dot net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 08:00:01 2025 UTC |
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>