#38768 [Opn->Bgs]: addChild to an empty node doesn't add a child
| From: | iliaa@php.net | Date: | Sun, 10 Sep 2006 17:37:36 +0000 |
| Subject: | #38768 [Opn->Bgs]: addChild to an empty node doesn't add a child | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-101965@lists.php.net to get a copy of this message | ||
ID: 38768
Updated by: iliaa@php.net
Reported By: vondi at vondi dot no-ip dot com
-Status: Open
+Status: Bogus
Bug Type: SimpleXML related
Operating System: Linux
PHP Version: 5.1.6
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
You are actually trying to create 2 new children, which won't
work. In your sample HTML the Connector node is the root node,
so to add children to it, you simply need to do
$xml->addChild('test');
or
$xml->test = 'nodeValue';
Previous Comments:
------------------------------------------------------------------------
[2006-09-10 11:48:31] vondi at vondi dot no-ip dot com
Description:
------------
Created a SimpleXMLObject with simplexml_load_string, then attempted to
add a child to the empty node.
However the the child node isn't created.
Reproduce code:
---------------
<?
$str="<Connector></Connector>";
$xml=simplexml_load_string($str,'SimpleXMLElement');
$xml->Connector->addChild('test');
echo $xml->asXML();
?>
Expected result:
----------------
<?xml version="1.0"?>
<Connector>
<test></test>
</Connector>
-- or --
<?xml version="1.0"?>
<Connector>
<test />
</Connector>
Actual result:
--------------
<?xml version="1.0"?>
<Connector/>
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=38768&edit=1