Copy link to clipboard
Copied
I'm trying to use ASP.NET to retrieve data from the sql server, place in inside an xml and sends the xml to flash to display the data.
However, I'm getting
TypeError: Error #1088: The markup in the document following the root element must be well-formed.
at news_fla::mainTimeline/loaded()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
This is my code:
ASP.NET
=======
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim adapter As SqlDataAdapter
Dim ds As New DataSet
Dim sql As String
Dim con As New SqlConnection("data source = GN80000798-0\SQLEXPRESS2008; initial catalog = EL; integrated security = true")
sql = "select * from news"
Try
con.Open()
adapter = New SqlDataAdapter(sql, con)
adapter.Fill(ds, "data")
con.Close()
Response.ContentType = "text/XML"
Response.HeaderEncoding = Encoding.UTF8
ds.WriteXml(Response.OutputStream, XmlWriteMode.WriteSchema)
MsgBox("Done")
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Flash
====
import flash.xml.*;
var newsrequest:URLRequest = new URLRequest("http://localhost:1179/DB/DB.aspx"); //ASP.NET development server
var newsloader:URLLoader = new URLLoader();
var newsxml:XML;
var dvar:URLVariables = new URLVariables();
dvar.dummy = "dummy";
newsrequest.data = dvar;
newsrequest.method = URLRequestMethod.POST;
newsloader.load(newsrequest);
newsloader.addEventListener(Event.COMPLETE, loaded);
titlenews.autoSize = TextFieldAutoSize.LEFT;
bodynews.autoSize = TextFieldAutoSize.LEFT;
function loaded(event:Event){
newsxml = new XML(event.target.data);
newsxml.ignoreWhitespace = true;
trace(newsxml);
}
HOWEVER, if i replace the
"ds.WriteXml(Response.OutputStream, XmlWriteMode.WriteSchema)"
with
"ds.WriteXml("C:\new.xml")
it works. But i dont wan a .xml file residing in the server. so i hope that the .xml file would be cleared off as soon as the request is done.
Did i do something wrong?
PS: I don't know if i post this in the correct section but since it's related to AS3, thats why i post it here. sorry if i made a mistake.
Copy link to clipboard
Copied
Please paste the following line as first statement in loaded function, also compare the output of the following line with expected output from ASP page.
trace(event.target.data);
The error is causing due to the fact that XML received is not well formed.
I guess the problem is with write XML you are getting some additional tag elements and these are not wellformed. so flash is giving error.