FLEX XML Handling

XML Handling

http://dis1.tistory.com/218
package net.dailyon.flex { import flash.display.Sprite; import flash.errors.IOError; import flash.events.Event; import flash.net.URLLoader; import flash.net.URLRequest; import flash.utils.getTimer; public class RSSParser extends Sprite { private var urlLoader:URLLoader; private var urlRequest:URLRequest; private var items:XMLList; public function RSSParser() { super(); this.urlLoader = new URLLoader(); this.urlRequest = new URLRequest("http://www.dailyon.net/rss"); this.loadXML(); } private function loadXML():void { try { trace("load시작: " + getTimer()); this.urlLoader.load(this.urlRequest); this.urlLoader.addEventListener(Event.COMPLETE, parse); trace("load끝: " + getTimer()); } catch(e:IOError) { e.getStackTrace(); } catch(e:SecurityError) { e.getStackTrace(); } catch(e:Error) { e.getStackTrace(); } finally { trace("load or fail"); } } private function parse(event:Event):void { trace("찍기시작: " + getTimer()); /* trace("\ndataFormat: \n" + this.urlLoader.dataFormat + "\nloadData: \n" + this.urlLoader.data); */ var xml:XML = XML(this.urlLoader.data); trace(xml.channel[0].item[0].title); trace(xml.channel[0].item[0].link); trace("끝"); } } }

예외처리
예외처리는 좁은 범위에서 넓은 범위로

timer

Leave a Reply

Close Menu