XML Output Formatting Issues

I’m having issues trying to get proper XML formatting with my output as below:

var loaderMC = _root.createEmptyMovieClip("loader_mc", 1234);
loaderMC.filename = "filename.xml";
loaderMC.data = "<blah> here's some data </blah>";
loaderMC.getURL("[http://server.com/saveData.php",](http://server.com/saveData.php%22,) '_blank', 'POST');

When I try to add additional lines I get validation errors in flash (Actionscript).

Plus when I append the XML header, flash thinks the tags represent the end of my data:

<?xml version="1.0" encoding="UTF-8"?>

The “1.0” ruins flashes ability to find the end of my data line.

How can I a) Format my output XML so that it saves locally in the proper format such as:

<?xml version="1.0" encoding="UTF-8"?>
     <blah>here's some data</blah>
        <moreblah>
           <evenMore>Third Aggregate</evenMore>
        </moreblah>

And b) how can I output flash restrictive characters without upsetting my flash?

Thanks a ton!