stop();
//----運行----
//加載XML
myXML = new XML();
myXML.ignoreWhite = true;
myXML.load(targetXML);
onEnterFrame = function () {
loadingXML();
};
//----變量聲明----
var ChannelArr = new Array();
itemNum = 0;
itemTitle = new Array();
itemCategory = new Array();
itemLink = new Array();
itemDescription = new Array();
//----函數聲明----
//分析XML
function perseXML() {
//將數據讀入數組ChannelArr
channelFolder = myXML.firstChild.childNodes[0].childNodes;
//定位到<channel>的子節點
channelNodesFolder = channelFolder.length;
for (i=0; i<channelNodesFolder; i++) {
switch (channelFolder[i].nodeName) {
case "title" :
channelTitle = channelFolder[i].childNodes[0].nodeValue;
break;
case "link" :
channelLink = channelFolder[i].childNodes[0].nodeValue;
break;
case "description" :
channelDescription = channelFolder[i].childNodes[0].nodeValue;
break;
case "pubDate" :
channelPubDate = channelFolder[i].childNodes[0].nodeValue;
break;
case "item" :
perseItem();
break;
}
}
}
function perseItem() {
itemNodesFolder = channelFolder[i].childNodes;
//定位到Item的子節點
itemNodesCount = itemNodesFolder.length;
for (j=0; j<itemNodesCount; j++) {
switch (itemNodesFolder[j].nodeName) {
case "title" :
itemTitle[itemNum] = itemNodesFolder[j].childNodes[0].nodeValue;
break;
case "category" :
itemCategory[itemNum] = itemNodesFolder[j].childNodes[0].nodeValue;
break;
case "link" :
itemLink[itemNum] = itemNodesFolder[j].childNodes[0].nodeValue;
break;
case "description" :
//trace(itemNodesFolder[j].childNodes[0].nodeValue);
itemDescription[itemNum] = itemNodesFolder[j].childNodes[0].nodeValue;
break;
}
}
itemNum++;
}
//----預加載XML----
function loadingXML() {
if (myXML.loaded) {
perseXML();
play();
delete this.onEnterFrame;
} else {
XMLpercent = Math.floor(myXML.getBytesLoaded()/myXML.getBytesTotal()*100);
if (isNaN(XMLpercent)) {
XMLLoading = "CONNECTING XML...";
XMLpercent = "0%";
} else {
XMLLoading = "LOADING XML...";
XMLpercent += "%";
}
//XML載入進度
}
}