AJAX初级应用-RSS无刷新聚合器的代码与下载第1/3页

2019-09-14 07:21:53王冬梅

     getId("loadifo").innerHTML = "加载完成"
         settime(ifodis)
         num(response)
        }
        else{
            getId("loadifo").innerHTML = "错误"+xmldoc.status+"点这里刷新";
        }
    }
}
//检查数据合法性
function trydata(nodeName,nodeName2){
    try{
        var nodeV = nodeName.firstChild.nodeValue;
    }catch(e){
        try{
            var nodeV = nodeName2.firstChild.nodeValue;
        }catch(e){
            var nodeV = "没有可用信息"
        }
    }
    return nodeV;
}
//记录集总数
function num(b){
    try{
        var titleNode = b.selectNodes("//rss/channel/title");
        var a = b.getElementsByTagName("item").length
        titleV = trydata(titleNode(0));
        getId("listnum").innerHTML = "共有"+a+"篇文章 来源于:"+titleV;
        setlist(a,b);
    }catch(e){}
}
if (top.location != self.location)top.location=self.location; 


//节目列表显示
//定义接收指向各个元素的节点信息的变量
var titleNode,linkNode,categoryNameNode,authorNode,pubDateNode,descriptionNode
//定义接收元素值的变量
var titleV,linkV,categoryNameV,authorV,pubDateV,descriptionV
//分类聚合
function setlist(a,b)
{
    var prograNode = b.getElementsByTagName("item");
    var adminlinkNode = b.selectNodes("//rss/channel/link");
    var titleNode = b.selectNodes("//rss/channel/item/title");
    var linkNode = b.selectNodes("//rss/channel/item/link");
    var categoryNode = b.selectNodes("//rss/channel/item/category");
    var authorNode = b.selectNodes("//rss/channel/item/author");
    var pubDateNode = b.selectNodes("//rss/channel/item/pubDate");