// *********************** Define the URL and parameters as variables and dynamically pass the value...
<? XML version = "1.0" encoding = "UTF-8" ?>
< MX: Application Xmlns: MX = "Http://www.macromedia.com/2003/mxml"
Initialize = "Myhttpdata. Send (); trace ('calling Service ');" >
< MX: script >
<! [CDATA [
VaR myurl: String = "http://www.bpurcell.org/blog/rss.cfm ";
VAR mode: String = "short ";
VaR mode2: String = "cat ";
VaR catid = "14 ";
]>
</ MX: script >
<! -- If you set resultformat to object it turns the Returning data into an object -->
< MX: httpservice URL = "{Myurl }" ID = "Myhttpdata" Method = "Get" Resultformat = "Object" >
< MX: Request >
< Mode > {Mode} </ Mode >
< Mode2 > {Mode2} </ Mode2 >
< Catid > {Catid} </ Catid >
</ MX: Request >
</ MX: httpservice >
< MX: textarea Text = "{Myhttpdata. Result. RDF. Channel. Title }" Width = "250" />
< MX: textarea Text = "{Myhttpdata. Result. RDF. item [0]. Description }"
Width = "250" Height = "200" />
< MX: textarea Text = "{Myhttpdata. Result }" Width = "250" Height = "500" />
</ MX: Application >
Method 2: Use xmllist to output complete XML data. The output data attribute is XML. <? XML version = "1.0" encoding = "UTF-8" ?>
< S: Application Xmlns: FX = "Http://ns.adobe.com/mxml/2009"
Xmlns: S = "Library: // ns.adobe.com/flex/spark"
Xmlns: MX = "Library: // ns.adobe.com/flex/halo"
Width = "1024" Height = "768" Backgroundcolor = "#020202" Creationcomplete = "Menus. Send ()" >
< FX: script >
<! [CDATA [
Import MX. Collections. arraycollection;
Import MX. rpc. Events. resultevent;
[Bindable]
Private var roomsxml: XML;
[Bindable]
Private var menuinfo: xmllist;
Protected function httpserviceappsresulthandler (Event: resultevent): void
{
Roomsxml = New XML (event. Result );
Menuinfo = roomsxml. node;
Trace (menuinfo );
//// The output data is:
<Node name = "living room space" url = "space1.xml"/>
<Node name = "kitchen space" url = "space1.xml"/>
<Node name = "bedroom space" url = "space1.xml"/>
<Node name = "restaurant space" url = "space1.xml"/>
<Node name = "bathroom space" url = "space1.xml"/>
<Node name = "children's room" url = "space1.xml"/>
<Node name = "other space" url = "space1.xml"/>
Trace (menuinfo [0]. @ name );
//// The output data is: Living room space
}
]>
</ FX: script >
< FX: Declarations >
< MX: httpservice ID = "Menus" Resultformat = "XML" URL = "Dataasset/rooms. xml" Result = "Httpserviceappsresulthandler (event )" /> /// Important: You must set resultformat = "XML" to output the XML data type"
</ FX: Declarations >
</ S: Application > Httpservice processes XML files Connasp. mxml
Code :
<? XML version = "1.0" encoding = "UTF-8"?>
<Mx: Application xmlns: MX = "http://www.aDobe.com/2006/mxml "layout =" absolute "creationcomplete =" productsrequest. Send () ">
<Mx: httpservice id = "productsrequest" url = "http: // localHost/flexasp_ 1.asp"/>
<Mx: DataGrid x = "20" Y = "80" id = "productgrid" width = "400" dataprovider = "{productsrequest. lastresult. guestbook. Guests}">
<Mx: columns>
<Mx: datagridcolumn headertext = "name" datafield = "name"/>
<Mx: datagridcolumn headertext = "message" datafield = "message"/>
</MX: columns>
</MX: DataGrid>
</MX: Application>
XML generation using ASP
Flexasp_1.asp
<%
Response. contenttype = "text/XML"
Response. charset = "UTF-8"
Set conn = server. Createobject ("ADODB. Connection ")
Conn. provider = "Microsoft. Jet. oledb.4.0 ;"
Conn. Open Server. mappath ("./flash_asp/database. mdb ")
SQL = "Select name, message from Guestbook"
Set rs = conn. Execute (SQL)
Rs. movefirst ()
Response. Write ("<? XML version = '1. 0' encoding = 'utf-8'?> ")
Response. Write ("<guestbook> ")
While (not Rs. EOF)
Response. Write ("<guest> ")
Response. Write ("<Name>" & RS ("name") & "</Name> ")
Response. Write ("<message>" & RS ("message") & "</message> ")
Response. Write ("</guest> ")
Rs. movenext ()
Wend
Rs. Close ()
Conn. Close ()
Response. Write ("</guestbook> ")
%>
Access Database
Database Name database. MDB
Table Name: Guestbook
Field: ID, name, messageThe XML file is normally displayed separately, and the DataGrid In Flex does not display data. Why answer:Dataprovider = "{productsrequest. lastresult. guestbook. Guest }"