tags that get decoded
$oldChars = array('<p>', '</p>');

// since I use CDATA and 

tags always together - I create an array // of what I want to replace the decoded

tags with. $newChars = array('', '

]]>'); // use the PHP string replace function to replace every decoded opening //

tag with a CDATA tag followed by a

tag, and also repeat this // with the closing

, replacing it with an encoded

tag followed // by a closing CDATA tag. $xmlcdRep = str_replace($oldChars, $newChars, $HTTP_RAW_POST_DATA); // use html entity encode to fix the remaining decoded html tags $xmlString = html_entity_decode($xmlcdRep); // hopefully by here - the decoded tags will be properly reformatted and // the xml can saved back to the server correctly // the only thing i don't know how to do is to preserve the visual // spacing structure so if you open the xml in dreamweaver or text // editor, it still retains it's original well laid out form. if(!fwrite($file, $xmlString)){ print "Error writing to XML-file"; }else{ print "XML File Saved"; } fclose($file); ?>