note 87742 added to function.simplexml-element-addChild

From: Date: Fri, 19 Dec 2008 00:19:45 +0000
Subject: note 87742 added to function.simplexml-element-addChild
Groups: php.notes 
Request: Send a blank email to php-notes+get-148338@lists.php.net to get a copy of this message
Here's an easy way to add a text node to a SimpleXMLElement without having to bring DOM into play: <?php $element = new SimpleXMLElement('<exclamation/>'); $element->addChild('//', 'Amazing!'); echo $element->asXML(); // <exclamation>Amazing!</exclamation> ?> Not sure if this qualifies as an undocumented feature or an overlooked bug (please comment), but it seems useful enough to me. ---- Server IP: 64.71.164.2 Probable Submitter: 166.82.250.175 ---- Manual Page -- http://www.php.net/manual/en/function.simplexml-element-addChild.php Edit -- https://master.php.net/note/edit/87742 Del: integrated -- https://master.php.net/note/delete/87742/integrated Del: useless -- https://master.php.net/note/delete/87742/useless Del: bad code -- https://master.php.net/note/delete/87742/bad+code Del: spam -- https://master.php.net/note/delete/87742/spam Del: non-english -- https://master.php.net/note/delete/87742/non-english Del: in docs -- https://master.php.net/note/delete/87742/in+docs Del: other reasons-- https://master.php.net/note/delete/87742 Reject -- https://master.php.net/note/reject/87742 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#148338) next »