AS3 retrieving xml from aspx page

坚强是说给别人听的谎言 提交于 2019-12-24 10:38:04

问题


I'm an AS3 noob on training wheels...

I have an XML Loader class which is doing what it's supposed to with a test.xml file, however I need the flash to read the xml written by an aspx file.

So I tried:

var urlRequest:URLRequest = new URLRequest("../xml/CaseStudyFlashAssets.aspx");

I get error #1090 (which I gather is because the aspx is not xml and it doesn't like it)

Can anyone help me get to the xml written by the aspx file?

Thanks

Mikey


回答1:


A frequent problem with xml being supplied from a WebForm is newlines occuring before the actual xml. When I generate xml in .Net, I usually use a Generic Handler instead of a WebForm. That way, you get better control of the output. When I have to use a WebForm (in some cases when working with a CMS, the easiest way to get the data to return is to extend a base class which subclasses Page), I do all the work in the code behind:

XmlDocument doc = new XmlDocument();
//build the document
Response.Clear();
Response.ContentType = "text/xml";
Response.Write(doc.OuterXml);
Response.Flush();
Response.End();

This way, all the gunk from the .aspx file is removed from the response.




回答2:


Is your XML well-formed in your ASPX page? Are you setting the ContentType property on your ASPX page to text/xml?



来源:https://stackoverflow.com/questions/811850/as3-retrieving-xml-from-aspx-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!