as 3读取xml实现代码
as3对xml的操作实在是太方便了(e4x ecmascript for xml 没错.就是ecmascript 如果js比较好的同学对这个也很熟悉吧)..
package
{
import flash.display.*;
import flash.text.*;
import flash.xml.*;
import flash.net.*;
import flash.events.event;
public class classsubfeed extends sprite
{
var temp:textfield;
var myxmlurl:urlrequest;
var myloader:urlloader;
var xmlurl:string;
var xmlcontent:xml;
public function classsubfeed()
{
temp = new textfield();
temp.x = 10;
temp.y = 10;
temp.;
temp.;
temp.border = true;
temp.bordercolor = 0x669900;
temp.multiline = true;
temp.htmltext = 'loading.....';
addchild(temp);
// xml地址
xmlurl = "http://www.111com.net/xml/5230.xml";
this.loadxml(xmlurl);
}
private function loadxml(xmlurl:string):void
{
myxmlurl = new urlrequest(xmlurl);
myloader = new urlloader(myxmlurl);
myloader.addeventlistener(event.complete, onloaded);
}
private function onloaded(event):void
{
xmlcontent = xml(myloader.data);
temp.htmltext = '已经读取feed,正在准备.....';
this.parsedata(xmlcontent);
}
private function parsedata(xmlcontent:xml):void
{
var rrstitle:string = xmlcontent.channel.title;
var rrslink:string = xmlcontent.channel.link;
temp.htmltext = "" + rrstitle + "
";
for each(var item:xml in xmlcontent..item)
{
var itemtitle:string = item.title.tostring();
var itemlink:string = item.link.tostring();
temp.htmltext += "
";
}
}
}
}
实例二,读取外部xml 文件
------------------------------readxml.as-------------------------------------------package
{
import flash.events.event;
import flash.net.urlloader;
import flash.net.urlrequest;
import flash.xml.xmldocument;
import flash.text.textfield;
import flash.text.textformat;
import flash.text.textfieldautosize;
import flash.display.displayobjectcontainer;
import flash.display.spritepublic class readxml extends sprite
{
private var myxml:xml;
private var myloader:urlloader;
private var string:string;
private var mystr:string=new string();
private var myxmlurl:urlrequest;
private var txt:textfield=new textfield();
private var format:textformat = new textformat();
public function readxml(myxmlurl:string):void
{
myxmlurl=new urlrequest(myxmlurl);
myloader=new urlloader();
myloader.addeventlistener(event.complete,xmlloaded);
myloader.load(myxmlurl);
}
public function xmlloaded(evt:event):void
{
myxml=new xml(evt.currenttarget.data);
mystr=this.myxml.question[0].@value;
txt.text=mystr;
txt.autosize = textfieldautosize.left;
txt.background = true;
txt.border = true;
format.font = "宋体";
format.color = 0x000000;
format.size = 15;
format.underline = false;txt.defaulttextformat=format;
txt.x=50;
txt.y=200;
trace(myxml);
trace(mystr);
}
public function returntext(target:displayobjectcontainer):void
{
target.addchild(txt);
}
}//end of class
}//end of package
我的博物馆故事 官方安卓版v1.61.2
我的博物馆故事是一款以消除为主题的经营养成类手游,在这里玩家
专业模拟飞行10 手机版v12.2.4
专业模拟飞行10安卓版是一款飞行休闲手游,顶尖的物理飞行引擎
动物起义战斗模拟器二琳同款 最新版v4.1.1
动物起义战斗模拟器是一个非常有趣的模拟类游戏,玩家可以召唤各
迷你世界七周年 安卓手机版v1.43.0
迷你世界7周年是一款由《迷你世界》官方推出的庆祝特别版本,在
劫后公司无限资源版 v1.0.5.1
劫后公司内置菜单版是游戏的破解版本,在该版本中为玩家提供了内