Reading External Xml Documents; Example: Loading Rss Data From The Internet - Adobe FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 Manual

Programming actionscript 3.0
Table of Contents

Advertisement

{
myXML.total.children()[0] = Number(myXML.total.children()[0])
}
trace(myXML.total); // 4.35;
If this code did not use the
string concatenation operator, and the
following:
01.003.95

Reading external XML documents

You can use the URLLoader class to load XML data from a URL. To use the following code in
your applications, replace the
var myXML:XML = new XML();
var XML_URL:String = "http://www.example.com/Sample3.xml";
var myXMLURL:URLRequest = new URLRequest(XML_URL);
var myLoader:URLLoader = new URLLoader(myXMLURL);
myLoader.addEventListener("complete", xmlLoaded);
function xmlLoaded(evtObj:Event):void
{
myXML = XML(myLoader.data);
trace("Data loaded.");
}
You can also use the XMLSocket class to set up an asynchronous XML socket connection
with a server. For more information, see the ActionScript 3.0 Language Reference.
Example: Loading RSS data from the
Internet
The RSSViewer sample application shows a number of features of working with XML in
ActionScript, including the following:
Using XML methods to traverse XML data in the form of an RSS feed.
Using XML methods to assemble XML data in the form of HTML to use in a text field.
330
Working with XML
+ Number(item.price.children()[0]);
function, the code would interpret the + operator as the
Number()
trace()
value in the example with a valid URL:
XML_URL
method in the last line would output the

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex

Table of Contents