Basically I have a script that updates an xml document in various places... However, I need the text to be in CDATA... So I attempted this:
$PrintQuestion->content->multichoice->feedback->hint->Passage->Paragraph->addChild('TextFragment', '<![CDATA[' . $value[0] . ']]>');
Unfortunately when I save the XML back to file, the < and > in cdata come up as their respective < and $gt; codes is there a way to avoid this?
Note: Our parser doesn't know how to read the <
and >
codes, so this is a serious issue
after doing a print_r of my simple_xml object, the < appears as itself in the source code!
It must be the domsave that is converting it into the entity code... any ideas how to disable this?
//Convert SimpleXML element to DOM and save
$dom = new DOMDocument('1.0');
$dom->preserveWhiteSpace = false;
$dom->formatOutput = false;
$dom->loadXML($xml->asXML());
$dom->save($filename);