I'm trying to create an xml document without converting html entities but when I create and save the file with DOMDocument the < and > characters are converted to < and > so trying to wrap copy within <![CDATA[]]> is proving problematic.
Example of my code below:
// Initiate the XML
$doc = new DOMDocument('1.0', 'UTF-8');
$doc->formatOutput = true;
$r = $doc->createElement("advertising");
$doc->appendChild($r);
// <ad>
$ad = $doc->createElement('ad');
// <TITLE>
$title = $doc->createElement('TITLE');
$title->appendChild($doc->createTextNode('<![CDATA['.$v_title.']]>'));
$ad->appendChild($title);
// </ad>
$r->appendChild($ad);
// Save xml
$doc->saveXML();
$doc->save('ads.xml');
Could anyone tell me how I prevent this?