The \"addChild\" method of SimpleXMLElement seems like it should be the right choice, but it apparently only takes strings representing the tagname of the new child.
Hey unknown. You have to use the DOMElement interface to your SimpleXML objects to achieve this.
');
$t = new DOMElement('child');
$dom = dom_import_simplexml($s);
$dom->appendChild($t);
echo $s->asXML();
//
If you need more specific details, let me know. There are several examples in the documentation and comments for the dom_import_simplexml() method too: http://php.net/dom_import_simplexml