欢迎来到福编程网,本站提供各种互联网专业知识!

javascript读取RSS数据

发布时间:2007-01-20 作者: 来源:转载
复制代码代码如下:javascript读取RSS数据javascript读取RSS数据新闻中心(摘自新浪网)NewsLoading...//Containerforticker.ModifyitsSTYLEattributetocustomizestyle:vartickercontainer=''varxmlsource="http://rss.mydrivers.com/Fitting_News.xml";varr

复制代码 代码如下:


javascript读取RSS数据



javascript读取RSS数据




新闻中心(摘自新浪网)






NewsLoading...





//Containerforticker.ModifyitsSTYLEattributetocustomizestyle:
vartickercontainer=''
varxmlsource="http://rss.mydrivers.com/Fitting_News.xml";
varroot;
vartitle;
varlink;
varitems;
varitem;
varimages;
varimage;
vardescription;
if(window.ActiveXObject)
{
//document.write("Microsoft.XMLDOM");
varxmlDoc=newActiveXObject("Microsoft.XMLDOM");
}
elseif(document.implementation&&document.implementation.createDocument)
{
//document.write("document.implementation.createDocument");
varxmlDoc=document.implementation.createDocument("","doc",null);
}
if(typeofxmlDoc!="undefined")
{
//document.write(tickercontainer)
xmlDoc.load(xmlsource)
}
functionfetchxml()
{
if(xmlDoc.readyState==4)
output()
else
setTimeout("fetchxml()",10)
}
functionoutput()
{
vartemp="";
root=xmlDoc.getElementsByTagName("channel")[0];
title=root.getElementsByTagName("title")[0];
//temp=title.firstChild.nodeValue+"

";
items=root.getElementsByTagName("item");
for(i=0;i<=items.length-1;i++)
{
item=items[i];
title=item.getElementsByTagName("title")[0];
link=item.getElementsByTagName("link")[0];
description=item.getElementsByTagName("description")[0];
temp=temp+""+title.firstChild.nodeValue+"

";
//temp=temp+""+description.firstChild.nodeValue+"

";
document.getElementById("container").innerHTML=temp;
}
}
if(window.ActiveXObject)
fetchxml()
elseif(typeofxmlDoc!="undefined")
xmlDoc.onload=output


相关推荐