|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #38768 addChild to an empty node doesn't add a child
Submitted: 2006-09-10 11:48 UTC Modified: 2006-09-11 18:57 UTC
From: vondi at vondi dot no-ip dot com Assigned:
Status: Not a bug Package: SimpleXML related
PHP Version: 5.1.6 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: vondi at vondi dot no-ip dot com
New email:
PHP Version: OS:


 [2006-09-10 11:48 UTC] vondi at vondi dot no-ip dot com
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:
 echo $xml->asXML();

Expected result:
<?xml version="1.0"?>

-- or --
<?xml version="1.0"?>
 <test />

Actual result:
<?xml version="1.0"?>


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-09-10 17:37 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

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->test = 'nodeValue';
 [2006-09-11 18:57 UTC] vondi at vondi dot no-ip dot com
Ok. Thank you very much for your reply and sorry for taking your time due to my limited programming skill and logic flaws.

Keep up the very good work!
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Thu Mar 23 02:03:37 2023 UTC