通过JavaScript读取RSS数据

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Javascript获取RSS数据源</title>
<script chartset="utf-8">
function list()
{
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async="false";
xmlDoc.load("http://special.allnet.cn/allnetevents/2006/rss.aspx");//RSS源的URL
var nodes=null;
a2="webLog";
nodes = xmlDoc.selectNodes("/rss/channel/item");
if(nodes==null)
allnet2006.innerText = "没有发现数据";

else
{
allnet2006.innerHTML = "";
xx=nodes.length;
if(xx>6)//控制列表长度
xx=6;//控制列表长度
for(i=0;i<xx;i++){
allnet2006.innerHTML +="<li><a href='" + nodes[i].selectSingleNode("link").text + "' rel='external'>" + nodes[i].selectSingleNode("title").text + "</a></li>";
}
}
}
</script>
</head>
<body onLoad="list()">
<div id="allnet2006"></div>
</body>
</html>

posted @ 2009-08-12 23:49  风影极光  阅读(318)  评论(0编辑  收藏  举报