Bug #47847 [Com]: importNode loses the namespace of an XML element.
Edit report at https://bugs.php.net/bug.php?id=47847&edit=1
ID: 47847
Comment by: hunthealth8 at gmail dot com
Reported by: robin2008 at altruists dot org
Summary: importNode loses the namespace of an XML element.
Status: Open
Type: Bug
Package: DOM XML related
Operating System: Ubuntu
PHP Version: 5.2.9
Block user comment: N
Private report: N
New Comment:
Healthhunt are sharing latest news about Disease Management, Lifestyle & Wellness, Men's
Mental Health etc. More info to visit:(https://healthhunt.net)github.com
Previous Comments:
------------------------------------------------------------------------
[2009-03-31 11:20:45] robin2008 at altruists dot org
Description:
------------
ImportNode don't treat namespace properly
Reproduce code:
---------------
<?php
// 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(' http://friend2friend.net ','f2f:a'));
echo 'DOM to add into is '.$aDOM->saveXML().chr(13);
$fromdom= DOMDocument::loadXML('<?xml version="1.0"?><f2f:data
xmlns:f2f=" http://friend2friend.net
"><f2f:servicereq xmlns=" http://friend2friend.net ">
<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);
$aDOM->appendChild($imported);
echo 'Result is '.$aDOM->saveXML();
?>
Expected result:
----------------
Namespace should be preserved
Actual result:
--------------
Namespace gets lost
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=47847&edit=1
Thread (4 messages)