javascript读取RSS数据_Javascript教程-查字典教程网
javascript读取RSS数据
javascript读取RSS数据
发布时间:2016-12-30 来源:查字典编辑
摘要:复制代码代码如下:javascript读取RSS数据javascript读取RSS数据新闻中心(摘自新浪网)NewsLoading...//...

复制代码 代码如下:

<html>

<head>

<title>javascript读取RSS数据</title>

<METAcontent="text/html;charset=utf-8"http-equiv=Content-Type/>

</head>

<bodyleftmargin="0"topmargin="0">

<font><h3align="center">javascript读取RSS数据</h3></font>

<br>

<tablewidth="90%"align="center"border="0"cellpadding=0cellspacing=0>

<tr>

<tdbgcolor=White><b>新闻中心</b><fontsize="-1">(摘自新浪网)</font><hr></td>

</tr>

<tr>

<tdbgcolor=White>

<divid="container">NewsLoading...</div>

</td>

</tr>

</table>

<scriptlanguage="JavaScript1.2">

//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+"<br>";

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+"<fontsize=-1><ahref="+link.firstChild.nodeValue+"target='_bank'>"+title.firstChild.nodeValue+"</a></font><br><br>";

//temp=temp+"<fontsize=-1>"+description.firstChild.nodeValue+"</font><br><br>";

document.getElementById("container").innerHTML=temp;

}

}

if(window.ActiveXObject)

fetchxml()

elseif(typeofxmlDoc!="undefined")

xmlDoc.onload=output

</script>

</body>

</html>

相关阅读
推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
  • 大家都在看
  • 小编推荐
  • 猜你喜欢
  • 最新Javascript教程学习
    热门Javascript教程学习
    编程开发子分类