Flash AS3.0, XML and E4X
ActionScript 3.0 changes things quite significantly. The good news is that the new approaches make life much easier. ActionScript 3.0 includes completely new XML functionality based on the E4X specification
In ActionScript 3.0, can target content in an XML object by using methods of the XML class to write E4X expressions.
Here I am giving an example. how to parse data through using different methods.
code:
package {
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.net.URLLoader;
import flash.net.URLRequest;public class main extends Sprite {
private var xmlMessage:XML;
private var xmlLoader:URLLoader;
private var xmlRequest:URLRequest;
public function main() {
init();
}
private function init() {
addChild(menuText);
var strXMLPath:String = “myXML.xml”;xmlLoader = new URLLoader();
xmlLoader.addEventListener(Event.COMPLETE,completeHandeler);
xmlLoader.load(new URLRequest(strXMLPath));
}
private function completeHandeler(event:Event):void {
xmlMessage = XML(event.target.data);
mText.text = xmlMessage.menuTitle;
}
}