<LoadingData>
<question>
<text>XML!!</text>
<answers>
<answer type="correct">correct!!correct!!</answer>
<answer type="wrong">wrong!!!!wrong!!!!</answer>
</answers>
</question>
</LoadingData>
<question>
<text>XML!!</text>
<answers>
<answer type="correct">correct!!correct!!</answer>
<answer type="wrong">wrong!!!!wrong!!!!</answer>
</answers>
</question>
</LoadingData>
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.net.URLLoader;
import flash.net.URLRequest;
public class Main extends Sprite
{
public function Main():void
{
init();
}
private function init():void
{
var xmlURL:URLRequest = new URLRequest("LoadingData.xml");
var xmlLoader:URLLoader = new URLLoader(xmlURL);
xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);
}
public function xmlLoaded(e:Event):void
{
var dataXML = XML(e.target.data);
trace(dataXML.question.text);
trace(dataXML.question.answers.answer[0]);
trace(dataXML.question.answers.answer[0].@type);
}
}
{
import flash.display.Sprite;
import flash.events.Event;
import flash.net.URLLoader;
import flash.net.URLRequest;
public class Main extends Sprite
{
public function Main():void
{
init();
}
private function init():void
{
var xmlURL:URLRequest = new URLRequest("LoadingData.xml");
var xmlLoader:URLLoader = new URLLoader(xmlURL);
xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);
}
public function xmlLoaded(e:Event):void
{
var dataXML = XML(e.target.data);
trace(dataXML.question.text);
trace(dataXML.question.answers.answer[0]);
trace(dataXML.question.answers.answer[0].@type);
}
}
}