<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<head>
<title>thisistest</title>
<scripttype="text/javascript">
varxmlHttp;
functioncreateXMLHttpRequest(){
if(window.ActiveXObject){
xmlHttp=newActiveXObject("Microsoft.XMLHTTP");
}
elseif(window.XMLHttpRequest){
xmlHttp=newXMLHttpRequest();
}
}
functionreadRSS(url){
createXMLHttpRequest();
xmlHttp.onreadystatechange=handleStateChange;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
functionhandleStateChange(){
if(xmlHttp.readyState==4){
if(xmlHttp.status==200){
ResultSet();
}
}
}
functionResultSet(){
varresults=xmlHttp.responseXML;
vartitle=null;
varitem=null;
varlink=null;
varauthor=null;
varpubDate=null;
vardescription=null;
//得到channel
varccc=results.getElementsByTagName("channel");
varheadtitle=ccc[0].getElementsByTagName("title")[0].firstChild.nodeValue;
varheadlink=ccc[0].getElementsByTagName("link")[0].firstChild.nodeValue;
varcell=document.createElement("div");
cell.innerHTML="<h1><ahref="+headlink+"target=_blank>"+headtitle+"</a></h1><br>";
document.getElementById("result").appendChild(cell);
//得到items
varitems=results.getElementsByTagName("item");
for(vari=0;i<items.length;i++){
item=items[i];
link=item.getElementsByTagName("link")[0].firstChild.nodeValue;
title=item.getElementsByTagName("title")[0].firstChild.nodeValue;
author=item.getElementsByTagName("author")[0].firstChild.nodeValue;
pubDate=item.getElementsByTagName("pubDate")[0].firstChild.nodeValue;
//description=item.getElementsByTagName("description")[0].firstChild.nodeValue;
varcell=document.createElement("div");
cell.innerHTML="<ahref="+link+"target=_blank>"+title+"</a><fontcolor=red>   作者:</font>"+author+"<br>";
document.getElementById("result").appendChild(cell);
//varcell1=document.createElement("div");
//cell1.innerHTML=description;
//document.getElementById("result").appendChild(cell1);
}
}
functionreadrss1()
{
varurl=document.getElementById("txturl").value;
if(url=="")
{
alert("请输入RSS地址");
}
else
{
readRSS(url);
}
}
vari=1;
varj=0;
functionread()
{
if(j==0)
{
readBlogjava();
window.setTimeout("testRead()",100);
}
}
functiontestRead()
{
window.setTimeout("read()",1000);
}
functionreadBlogjava()
{
switch(i)
{
case(1):
i++;
readRSS("http://www.blogjava.net/rss.aspx");
break;
case(2):
i++;
readRSS(http://beginner.blogjava.net/rss.aspx);
break;
case(3):
i++;
readRSS(http://general.blogjava.net/rss.aspx);
break;
case(4):
i++;
readRSS(http://life.blogjava.net/rss.aspx);
break;
//博客园的
case(5):
i++;
readRSS(http://www.cnblogs.com/rss.aspx);
break;
case(6):
i++;
readRSS(http://beginner.cnblogs.com/rss.aspx);
break;
case(7):
i++;
readRSS(http://life.cnblogs.com/rss.aspx);
break;
case(8):
i++;
readRSS(http://misc.cnblogs.com/rss.aspx);
break;
case(9):
i++;
readRSS(http://cio.cnblogs.com/rss.aspx);
break;
case(10):
i++;
readRSS(http://news.cnblogs.com/rss.aspx);
break;
case(11):
i++;
readRSS(http://bookreview.cnblogs.com/rss.aspx);
break;
case(12):
i++;
readRSS(http://job.cnblogs.com/rss.aspx);
break;
case(13):
i++;
readRSS(http://gis.cnblogs.com/rss.aspx);
break;
case(14):
i++;
readRSS(http://clubs.cnblogs.com/rss.aspx);
break;
case(15):
i++;
readRSS(http://software.cnblogs.com/rss.aspx);
break;
default:
alert("加载完毕!");
i++;
j++;
break;
}
}
</script>
</head>
<bodyonload=testRead()>
<h1>ajax读rss示例</h1>
<form>
输入一个RSS地址:<inputtype="text"value="http://www.blogjava.net/wujun/rss.aspx"size=50id="txturl">
<inputtype="button"value="查看"onclick="readrss1()">
<inputtype="button"onclick="hideobject()"value="test">
</form>
<divid="result"></div>
<EMBEDstyle="POSITION:absolute;top:1px;left:1px;"align=right
src=http://www.nice.or.jp/~mosmos/free/f105.swfwidth=200height=200
type=application/x-shockwave-flash;quality="high"wmode="transparent"></EMBED>
</body>
</html>