note 112204 added to simplexmlelement.addchild

From: Date: Thu, 16 May 2013 14:31:22 +0000
Subject: note 112204 added to simplexmlelement.addchild
Groups: php.notes 
Request: Send a blank email to php-notes+get-194827@lists.php.net to get a copy of this message
To complete Volker Grabsch's comment, stating : "Note that although addChild() escapes "<" and ">", it does not escape the ampersand "&"." To work around that problem, you can use direct property assignment such as : <?php $xmlelement->value = 'my value < > &'; // results in <value>my value &lt; &gt; &amp;</value> ?> instead of doing : <?php $xmlelement->addChild('value', 'my value < > &'); // results in <value>my value &lt; &gt; &</value> (invalid XML) ?> See also: http://stackoverflow.com/questions/552957 (Rationale behind SimpleXMLElement's handling of text values in addChild and addAttribute) HTH ---- Server IP: 69.147.83.199 Probable Submitter: 80.118.1.87 ---- Manual Page -- http://php.net/manual/en/simplexmlelement.addchild.php Edit -- https://master.php.net/note/edit/112204 Del: integrated -- https://master.php.net/note/delete/112204/integrated Del: useless -- https://master.php.net/note/delete/112204/useless Del: bad code -- https://master.php.net/note/delete/112204/bad+code Del: spam -- https://master.php.net/note/delete/112204/spam Del: non-english -- https://master.php.net/note/delete/112204/non-english Del: in docs -- https://master.php.net/note/delete/112204/in+docs Del: other reasons-- https://master.php.net/note/delete/112204 Reject -- https://master.php.net/note/reject/112204 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#194827) next »