Transfer data from Sql Server 2005 to Adobe Flex 2.0 as xml

Posted on 2007-08-11
Last Modified: 2012-06-27
Why is Adobe Flex 2.o  giving me the error "The markup in the document precending the root element must be well-formed" when trying to load xml via an .aspx script produced string, yet it works if I save the string as a .xml?

I am calling the script in Flex as such

<mx:XML id="treeData" source="bin\xml\user_list.aspx" />

THis is my .aspx

<?xml version="1.0" encoding="iso-8859-1"?>
<%@ Page Language="VB" Debug="true" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Web" %>


Dim ConnString as String  = "-------------------------------------"

'      get users from database
Dim userConn As New SqlConnection( ConnString )

Dim userSQL as String = "SELECT * FROM userAccounts ORDER by last_name ASC;"
Dim userCommand As New SqlCommand(userSQL, userConn)
Dim userDataReader As SqlDataReader = userCommand.ExecuteReader

Dim dataOutPut as String = ""                                                    

dataOutPut += "<nodeTop>"

While userDataReader.Read()   '      read move count forward by one, returns false if next one does not exist
'WHILE  groupCount < 10

            dataOutPut += "<node label='" & userDataReader("user_name") & "'>"
          dataOutPut += "<node user_name='" & userDataReader("user_name") & "'/>"
            dataOutPut += "</node>"

End While


dataOutPut += "</nodeTop>"




I really just need to know the best way to share data between Flex and SQL Server without resorting to web or data services.  I want to do it strickly through scripts or if sql server has something better im all ears.  Thanks
Question by:DILORENZO
    LVL 58

    Expert Comment

    Even though you are producing the correct xml the content type would still be text/html. Adobe Flex might be expecting text/xml. So add

    Response.ContentType = "text/xml"

    before Response.Cache line and try it again.

    Author Comment

    I still get the same results.  Im pulling my hair out here because I use to have this application working fine.  I just got a new computer and setting everything up like my old on has been a nightmare.
    LVL 58

    Expert Comment

    I don't know how Adobe Flex works but some browsers cache the ContentType and need a restart. Is there something like that in Adobe Flex?

    Author Comment

    I can not believe I spent hours on this.

    The reference...

    <mx:XML id="treeData" source="bin/xml/menu.aspx" />

    Should have been..

    <mx:XML id="treeData" source="http://localhost/xml/menu.aspx" />

    It has to be absolute rather than relative.  That is a kick in the pants.  Thank you for your help
    LVL 1

    Accepted Solution

    Closed, 125 points refunded.
    Community Support Moderator

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Introduction A frequently used term in Object-Oriented design is "SOLID" which is a mnemonic acronym that covers five principles of OO design.  These principles do not stand alone; there is interplay among them.  And they are not laws, merely princ…
    In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
    Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…
    Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now