System.useCodepage = true;
import mx.xpath.XPathAPI;
var rssfeed_xml:XML = new XML();
rssfeed_xml.ignoreWhite = true;
rssfeed_xml.onLoad = function(sucess:Boolean) {
if (sucess) {
var thePath_str:String = "/rss/channel/item/title";
var title_array:Array = XPathAPI.selectNodeList(this.firstChild, thePath_str);
for (var i:Number = 0; i<title_array.length; i++) {
trace(title_array[i].firstChild.nodeValue);
}
}
};
rssfeed_xml.load("http://www.flash-mx.com/news/index.xml");
//
xml구조만 알면 어떠한 항목이라도 바로 배열화 시켜주는 너무 멋진....메소드네요...^^
몰랐을때는 xml구조에 따라서 차일드에 어쩌구 저쩌구 정말 복잡 다감 했는데 한방에 해결이네요..*_*
XPathAPI는 절대경로, 상대경로 와일드카드(*)등의 사항에 관한 지원이 가능합니다.
XPathAPI의 메소드
------------------------------------------------------------------------------
XPathAPI.getEvalString () : 특정 노드에 대한 문자열 반환
XPathAPI.selectNodeList () : 선택된 노드들을 배열로 리턴
XPathAPI.selectSingleNode () : 특정 노드 리턴
XPathAPI.setNodeValue () : 특정 노드의 노드값 변경
------------------------------------------------------------------------------
http://download.macromedia.com/pub/documentation/en/flash/fl8/XpathAPI.pdf
죄다 영문이라 문제가 있긴 하지만.....예제가 있으니 한번들 해보세요...^^
TAG. Action Script


::: 사람과 사람의 교감! 人터넷의 첫 시작! 댓글을 달아주세요! :::