|  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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
33 + 48 = ?
Subscribe to this entry?

 [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: Mon May 29 20:03:40 2023 UTC