I am trying to get some basic data passed from PHP to Flash. From reading on the topic I understand the best way is to create XML with PHP then read it in Flash. I am trying to start out simple so here is my PHP code:
<?php
header('Content-Type: text/xml');
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
echo "<userData>";
echo "<firstName>John</firstName>";
echo "<lastName>Smith</lastName>";
echo "</userData>";
?>
And here is my Flash code:
var xml:XML = new XML();
var url:URLRequest = new URLRequest("data.php");
var loader:URLLoader = new URLLoader(url);
loader.addEventListener("complete", xmlLoaded);
function xmlLoaded(event:Event):void
{
xml = XML(loader.data);
trace("Data loaded.");
trace (loader.data);
};
I've seen some tutorials that use this approach and it works however in Flash I receive this error:
TypeError: Error #1088: The markup in the document following the root element must be well-formed.
Can anyone determine why I get this error or provide another way of doing this?