How store xml file special characters values in its as it is?

EduGovkos

New Member
I am using my xml file to store special chars.This is my original file \[code\]<root> <popups> <popup id="1"> <text1> <![CDATA[dynamic text popup 2a]]> </text1> <text2> <![CDATA[dynamic text popup 2b]]> </text2> </popup> </popups></root>\[/code\]Now when I use php to save special chars eg , it becomes like that \[code\]<root> <popups> <popup id="1"> <text1><![CDATA[Hello world]]></text1> <text2><![CDATA[asassa]]></text2> </popup> </popups></root>\[/code\]I have used the following code :\[code\]$this->xmlDocument = simplexml_load_file("xml/conf.xml"); $pages_node = $this->xmlDocument->xpath("/root/popups/popup[@id=1]"); $name = $_POST['popup-name']; $editor1 = trim(strip_tags($_POST['editor1'])); $editor2 = trim(strip_tags($_POST['editor2'])); if (!empty($name)){ if (!empty($editor1)){ $pages_node[0]->text1 = "<![CDATA[".$editor1."]]>"; } if (!empty($editor2)){ $pages_node[0]->text2 = "<![CDATA[".$editor2."]]>" ; } $this->xmlDocument->asXml($this->basePath() . "conf/conf.xml"); }\[/code\]How can I save the special chars as they are without needing to encode them?
 
Back
Top