How to write CDATA using SimpleXmlElement?
Got it! I adapted the code from this great solution (archived version): <?php // http://coffeerings.posterous.com/php-simplexml-and-cdata class SimpleXMLExtended extends SimpleXMLElement { public function addCData( $cdata_text ) { $node = dom_import_simplexml( $this ); $no = $node->ownerDocument; $node->appendChild( $no->createCDATASection( $cdata_text ) ); } } $xmlFile=”config.xml”; // instead of $xml = new SimpleXMLElement( ‘<site/>’ ); $xml = new SimpleXMLExtended( … Read more