I have this code for creating and updating an xml file:
<?php $xmlFile = 'config.xml'; $xml = new SimpleXmlElement('<site/>'); $xml->title = 'Site Title'; $xml->title->addAttribute('lang', 'en'); $xml->saveXML($xmlFile); ?>
This generates the following XML file:
<?xml version="1.0"?> <site> <title lang="en">Site Title</title> </site>
Question: is there a way to add CDATA using this method / method to generate the xml code below?
<?xml version="1.0"?> <site> <title lang="en"><![CDATA[Site Title]]></title> </site>
xml php cdata simplexml
quantme Jun 07 '11 at 3:00 2011-06-07 03:00
source share