用js读取blog RSS文件

| No Comments | No TrackBacks

代码如下
---------index.htm---------

<!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>Test</title>
</head>

<body onLoad="list()">
<script src="http://7thpark.com/parklog/loadrss.js"></script><div id="li"></div></body>
</html>


---------loadrss.js---------

/ JavaScript Document
function list()
{
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM")
xmlDoc.async="false"
xmlDoc.load("http://7thpark.com/parklog/rss.xml")
/*读取远程xml数据源,可以使用本地数据源,但要以index.html为基点,
这里应该写为index.html在http://7thpark.com/06/下面,所以为../parklog/rss.xml*/
var nodes=null
a2="webLog"
nodes = xmlDoc.selectNodes("/rss/channel/item")//读取节点,筛选节点最低端用item[title='xxx']或者//last
if(nodes==null)
li.innerText = "没有发现数据"
/* li为载入数据的html标签的id
例如调用时<script src="http://7thpark.com/parklog/loadrss.js"></script><div id="li"></div>*/
else
{
li.innerHTML = ""
xx=nodes.length
if(nodes.length>15)//控制列表长度
xx=15//控制列表长度
for(i=0;i<xx;i++)
li.innerHTML +="<a href='" + nodes[i].selectSingleNode("link").text + "' target='_blank'>" + nodes[i].selectSingleNode("title").text + "</a><br/>"
}
}

No TrackBacks

TrackBack URL: http://www.wujianrong.com/mt-tb.cgi/761

Leave a comment

About this Entry

This page contains a single entry by kevinwu published on June 22, 2006 5:00 PM.

自制“移动梦网” was the previous entry in this blog.

2006世界杯16强对决 is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.