
June 11th, 2009, 11:08 AM
|
|
|
|
Special Characters in XML Document... Boo
This is the link to the thread in PHP and I don't mean to double post but I need some help! I think the problem lies with my PHP code, but maybe you XML guys have run across this problem before as well.
I'm trying to change a value of a XML document; however, I need to wrap the text around a CDATA tag. When I do that the < and > gets converted to < and > so the document doesn't save correctly. I eyed around for "htmlspecialchars_decode" but I still just can't quite figure it out. Here is a sample of the code I'm working with.
PHP Code:
$doc = new SimpleXMLElement('tfile_main.xml', null, true);
$var = "TEST";
$doc->section[0]->item[2] = "<![CDATA[$var]]>";
$doc->asXML("tfile_main.xml");
That saves:
<![CDATA[TEST]]>
Rather than saving the actual symbols. How can I save that information in the true state with the actual symbols? Thank you in advance!
|