Very, very lost here. I've created some SimpleXML using 'new SimpleXMLElement' and added a few child nodes using 'addChild'. I saved it to an XML document on my server, but it was one long string. To fix this, I imported the simpleXML over to DOM. The code is
$doc = new DOMDocument('1.0');
$doc->formatOutput = true;
$domnode = dom_import_simplexml($xml);
$domnode = $doc->importNode($domnode, true);
$domnode = $doc->appendChild($domnode);
$doc->save("xxx.xml");
Now my XML looks great but I need to add some CDATA tags. I'm trying to access the nodes that need CDATA tags and use 'createCDATASection' to add them in. However, I keep getting errors around not be able to convert the element to a string. My final XML structure is below. I'm trying to add CDATA tags for the Description nodes.
XML
<TW>
<Item>
<User></User>
<Description></Description>
<Location></Location>
<Time></Time>
</Item>
</TW>
<Item>
<User></User>
<Description></Description>
<Location></Location>
<Time></Time>
</Item>
</TW>