# CDATA tags don't appear in XML file when saved

**URL:** <https://forum.kirupa.com/t/cdata-tags-dont-appear-in-xml-file-when-saved/145759>\
**Category:** Uncategorized\
**Created:** [April 25, 2005, 4:54pm UTC](https://forum.kirupa.com/t/cdata-tags-dont-appear-in-xml-file-when-saved/145759 "2005-04-25T16:54:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![birgit](https://avatars.discourse-cdn.com/v4/letter/b/c5a1d2/32.png) [@birgit](https://forum.kirupa.com/u/birgit)\
**Post date:** [April 25, 2005, 4:54pm UTC](https://forum.kirupa.com/t/cdata-tags-dont-appear-in-xml-file-when-saved/145759/1 "2005-04-25T16:54:11Z")

</div>

When sending an XML string which includes CDATA tags to the server, the  
XML file is saved correctly but the CDATA tags disappear.

In the Flash movie I create a variable (xmlString) to which contains  
some lines with CDATA tags, for example::

xmlString += " \<material\>\<mattext  
texttype=‘text/html’\>\<![CDATA["+currentString[j]+"]]\>\</mattext\>\</material\>  
";

I create an XML object and send the string to a PHP script on the  
server:

```
    addActivity = new XML(xmlString); 
    addActivity.contentType = "text/xml"; 
    addActivity.ignoreWhite = true; 
    addActivity.sendAndLoad("addActivity.php", moXML); 

```

The PHP script looks like this:

\<?php  
$my\_xml = $GLOBALS[“HTTP\_RAW\_POST\_DATA”];  
$xml\_output = simplexml\_load\_string($my\_xml);  
$filename=$xml\_output-\>filename;  
$handle= fopen($filename,‘w’);  
fwrite($handle, “$HTTP\_RAW\_POST\_DATA”);  
fclose($handle);  
echo $my\_xml;  
?\>

The file is saved but the CDATA tags disappear. Any ideas as to why this  
is happening? Any help would be appreciated.

Birgit
