go-deep

zhuanlan.zhihu.com/paper-reading

as3 解析xml 核心代码

private var bossInfors : Array = [];

 

 

readBossMessage("assets/ui/daily/activityBossInf.xml");

 

 

 

 

private function readBossMessage(textUrl : String):void
  {
   var loader : URLLoader = new SafeURLLoader();
   loader.dataFormat = URLLoaderDataFormat.TEXT;
   loader.addEventListener(Event.COMPLETE,function (e:Event):void{    
    getBossInfo(e.target.data);
    

//读完之后的工作

 


   });
   var url : String = ApplicationConfig.ASSETS_PATH1 + textUrl;   //常量
   loader.load(new URLRequest(url));
  }

 

 

 

 private function getBossInfo(text:String):void{  //text 在断点可以看到读来的源数据
   var xml:XML = new XML(text);
   var list:XMLList = xml.child("boss");
   for each(var node:XML in list){
    var obj : Object = new Object();
    obj.name = node["bossname"].toString();     //obj.name可以自己命名 ,后面bossname是节点名字
    obj.x = node["x"].toString();
    obj.y = node["y"].toString();
    obj.map = node["map"].toString();
    obj.id = node["bossId"].toString();
    obj.time = node["refresh"].toString();
    obj.level = node["level"].toString();
    obj.continent = node["continent"].toString();
    obj.mapname = node["mapname"].toString();
    obj.amount = node["amount"].toString();
    obj.defylevel = node["defylevel"].toString();
    obj.reward = node["reward"].toString();
    obj.mapname = buildBossLinkObject(obj);
    
    bossInfors.push(obj);
   }
   
  }
  
  private function buildBossLinkObject(source:Object):Object{     //节点中的节点
   var object:Object = new Object();
     object.id = 0;
   object.name = source.mapname;
   object.x = source.x;
   object.y = source.y;
   object.map = source.map;
   return object;
  }

阅读更多
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/guotong1988/article/details/7397897
上一篇MySQL优化
下一篇SQLiteOpenHelper
想对作者说点什么? 我来说一句

as3解析excel2010

2012年12月18日 22KB 下载

没有更多推荐了,返回首页

关闭
关闭