I'm using the following code to add dynamic child to an xml node
 <?php
   $recordXML = new SimpleXMLElement("<Record></Record>");
   $rowXML = $recordXML->addChild('row');
   foreach ($array as $column => $column_value) {
                $rowXML->addChild($column,$column_value );
            }
This code gives "unterminated entity reference" warning! when there is an ampresand & in any of the $column_value, I know & can be escaped If we assign the child content as below
 $rowXML->column_name = "text & content";
 // gives <row><column_name>text & content </column_name></row>
 // without any warning
Now how to use this method to add dynamic child node with ampresand escaping ?
                        
Basically to make it work for you would would have to do something like this: