xml - PHP SimpleXMLElement: How to add dynamic child with ampersand escaping -


i'm using following code add dynamic child xml node

 <?php    $recordxml = new simplexmlelement("<record></record>");    $rowxml = $recordxml->addchild('row');    foreach ($array $column => $column_value) {                 $rowxml->addchild($column,$column_value );             } 

this code gives "unterminated entity reference" warning! when there ampresand & in of $column_value, know & can escaped if assign child content below

 $rowxml->column_name = "text & content";  // gives <row><column_name>text &amp; content </column_name></row>  // without warning 

now how use method add dynamic child node ampresand escaping ?

basically make work would have this:

$rowxml->{$column} = $column_value; 

Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -