I have this code to create and update xml file:
\');
$xml->title
You can also create a helper function for this, if you'd rather not extend SimpleXMLElement:
/**
* Adds a CDATA property to an XML document.
*
* @param string $name
* Name of property that should contain CDATA.
* @param string $value
* Value that should be inserted into a CDATA child.
* @param object $parent
* Element that the CDATA child should be attached too.
*/
$add_cdata = function($name, $value, &$parent) {
$child = $parent->addChild($name);
if ($child !== NULL) {
$child_node = dom_import_simplexml($child);
$child_owner = $child_node->ownerDocument;
$child_node->appendChild($child_owner->createCDATASection($value));
}
return $child;
};