|  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
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-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 21 15:01:35 2024 UTC