Reputation: 6399
I have created an aspx page which dynamicaly creates an xml string and posts it back to the client.
protected void Page_Load(object sender, EventArgs e)
{
Response.Clear();
Response.ContentType = "text/xml";
Response.ContentEncoding = Encoding.UTF8;
var flashAssets = Asset.GetScrollingFlashAssets();
var xmlResponse = new StringBuilder(@"<?xml version=""1.0"" encoding=""UTF-8"" ?><assets>");
flashAssets.ForEach(asset => xmlResponse.Append(@"<asset>handlers/ImageHandler.ashx?liAssetID=" + asset.AssetID + "</asset>"));
xmlResponse.Append("</assets>");
Response.Write(xmlResponse.ToString());
}
It creates valid XML and when I save this code to a static .xml file the flash can read it fine, though when it tried to read it from the ASPX it fails with "1090 XML parser failure: element is malformed".
I do not have http compression on.
Flash code.
//---------loading the external xml file-------
var urlRequest:URLRequest = new URLRequest("../xml/CaseStudyFlashAssets.aspx");
var urlLoader:URLLoader = new URLLoader();
var myXML:XML = new XML();
var xmlList:XMLList;
myXML.ignoreWhitespace = true;
urlLoader.addEventListener(Event.COMPLETE,fileLoaded);
urlLoader.load(urlRequest);
Any ideas?
Upvotes: 0
Views: 1989
Reputation: 6307
It sounds like when flash calls the aspx page it gets a different response than you're expecting, try using this fileLoaded function:
public function fileLoaded(event:Event):void{
trace('urlLoader.data is ' + urlLoader.data);
try{
var xmlData:XML = XML(urlLoader.data);
} catch (e:Error) {
trace('Error creating XML: ' + e);
}
}
which should hopefully give you some more info about whats going wrong.
Upvotes: 1