#47490 [Opn->Bgs]: insertBefore can lose the namespace of an XML element
| From: | chregu@php.net | Date: | Tue, 24 Feb 2009 12:09:15 +0000 |
| Subject: | #47490 [Opn->Bgs]: insertBefore can lose the namespace of an XML element | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-134158@lists.php.net to get a copy of this message | ||
ID: 47490
Updated by: chregu@php.net
Reported By: robin2008 at altruists dot org
-Status: Open
+Status: Bogus
Bug Type: DOM XML related
Operating System: Ubuntu
PHP Version: 5.2.8
New Comment:
You have to use createElementNS if you want to create namespaced
elements.
Previous Comments:
------------------------------------------------------------------------
[2009-02-24 11:42:54] robin2008 at altruists dot org
Description:
------------
If the namespace of the insertBefore()'d element equals that of its
parent, it loses the xmlns attribute, so becomes unnamespaced:( !
Reproduce code:
---------------
<?php
$main= DOMDocument::loadXML('<?xml version="1.0"?><f2f:no-xmlns
xmlns:f2f="http://friend2friend.net"/>');
$new= $main->createElement('new');
$new->setAttribute('xmlns', 'http://friend2friend.net');
echo 'Main document= '.$main->saveXML().chr(13);
echo 'New element= '.$main->saveXML($new).chr(13).chr(13);
$main->firstChild->insertBefore($new, $main->firstChild->firstChild);
echo 'insertBefore() changes <new> into an unnamespaced node iff its NS
matched the parent node :-( '.$main->saveXML();
?>
Expected result:
----------------
Shouldn't lose the namespace. i.e.
<f2f:no-xmlns
xmlns:f2f="http://friend2friend.net"><f2f:new/></f2f:no-xmlns>
Actual result:
--------------
Loses the NS:
<f2f:no-xmlns
xmlns:f2f="http://friend2friend.net"><new/></f2f:no-xmlns>
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=47490&edit=1