Special chars & xml send method

I’m sending an xml file from flash to php, so php can save it to the servers filesystem.
It works great, except when there’s a node with a special char like a quote in it.

My actionscript code is like this:


xmlExport.xmlDecl = "xml=";
xmlExport.sendAndLoad("xmlexport.php", xmlExportStatus);

And my php code is like this:


fwrite($handle, stripslashes(urldecode($_POST['xml'])));

Both somewhat simplified, but this is what matters I think.
I’m not sure about the urldecode part, but I’ve got this problem always, no matter if I use it or not.

I’ve traced the xml object, and I see that the quote is converted to ’ then. That’s great, but when php writes it, it stops there, so I end with only half of an xml file.