How can I use the createCDATASection() method with simpleXml?

chcomeuxaaa

New Member
I want to insert a cdata in n xml but I have my base codes with simplexml which I cannot change, so I am looking for an alternative to modify my current codes that is convert simplexml codes using domImport and use its method ..Here are my codes How can I create a DOmDocument and DomElement with these to be able to use the createCDATASection() and append it to my xml file ?conf.xml\[code\]<root> <news> <text1> text1 </text1> <text2> text2 </text2> </news></root>\[/code\]I have done something like that but still it doesnot work\[code\] $this->xmlDocument = simplexml_load_file($this->basePath() . "xml/conf.xml");$nodeName = $_GET['edit']; $news_node = $this->xmlDocument->xpath('/root/news'); $domnewsNode = dom_import_simplexml($news_node[0]); $dom = $domnewsNode -> ownerDocument; $dom -> createCDATASection("test"); $dom_sxe = $dom->importNode($domnewsNode, true); $dom_sxe = $dom->appendChild($dom_sxe); echo $dom->saveXML();\[/code\]
 
Back
Top