PHP - Xmlwriter And Cdata
I'm trying to create an RSS feed.
I use following codes. It successfully creates xml feed. Code: [Select] $feed->startElement("item"); $feed->writeElement('title', $arrayText[1]); But the output is like this: Code: [Select] <title>viyana'da operan&#305;n ortas&#305;ndan ge&#231;en t&#252;rkler</title> I suppose that i should make CDATA for $arrayText[1] but i couldn't figure how.. Thank you. Similar TutorialsI'm tearing my hair out trying to work with "simple" XML for the first time. I'm building a small CMS for a Flash based site and the content is held in an XML file. My problem is that many of the copy fields are XML CDATA fields. On the one hand, with: $xml = simplexml_load_file($file, 'SimpleXMLElement', LIBXML_NOCDATA); I can pull the data out of that node and the CDATA tags are stripped. My issues come with trying to save the data with: file_put_contents($file, $xml->asXML()); Problems a a) tags are interpreted with their HTML entity equivalents. I don't want this to happen as it's a CDATA field being read by Flash. I gather this is coming from the asXML method because even if I do an html_entity_decode on the $_POST data it's still being converted. b) because of the above, there's no way to add the CDATA tags because they also have their charachters converted. SimpleXML so far has been anything but simple for me Has anyone ever run into this? Is there a way to save the file back in a way that will just keep my data exactly as is and also allow me to add the CDATA tags back in? |