zoukankan
html css js c++ java
用ajax解析rss简单例子
<
script
language
="javascript"
>
var
bloglist
=
new
Array();
var
xmlHttp
=
new
ActiveXObject(
"
Msxml2.XMLHTTP
"
);
function
startload()
{
xmlHttp.open(
"
GET
"
,
"
http://www.cnblogs.com/zwl12549/Rss.aspx
"
,
true
);
xmlHttp.onreadystatechange
=
function
()
{
if
(xmlHttp.readystate
==
4
&&
xmlHttp.status
==
200
)
{
var
xmldom
=
xmlHttp.responseXML;
var
channel
=
xmldom.documentElement.childNodes.item(
0
);
var
itemlist
=
channel.childNodes;
for
(
var
i
=
0
;i
<
itemlist.length;i
++
)
{
var
node
=
itemlist.item(i);
if
(node.tagName
==
"
title
"
)
{
blogtitle.innerHTML
=
node.text;
}
if
(node.tagName
==
"
description
"
)
{
blogdescription.innerHTML
=
node.text;
}
if
(node.tagName
==
"
generator
"
)
{
bloggenerator.innerHTML
=
node.text;
}
if
(node.tagName
==
"
item
"
)
{
bloglist[bloglist.length]
=
node.childNodes;
}
}
showitem(bloglist[
0
]);
}
}
xmlHttp.send(
null
);
}
function
showitem(itemlist)
{
for
(
var
i
=
0
;i
<
itemlist.length;i
++
)
{
var
node
=
itemlist.item(i);
if
(node.tagName
==
"
title
"
)
{
itemtitle.innerHTML
=
node.text;
}
if
(node.tagName
==
"
link
"
)
{
itemlink.href
=
node.text;
}
if
(node.tagName
==
"
description
"
)
{
description.innerHTML
=
node.text;
}
if
(node.tagName
==
"
author
"
)
{
author.innerHTML
=
node.text;
}
if
(node.tagName
==
"
pubDate
"
)
{
pubDate.innerHTML
=
node.text;
}
}
}
</
script
>
<
body
onload
="startload()"
>
<
font
color
="blue"
><
a
id
="bloglink"
href
="#"
><
div
id
="blogtitle"
></
div
></
a
></
font
><
br
/>
By
<
font
color
="blue"
><
div
id
="bloggenerator"
></
div
></
font
><
br
/>
<
font
color
="blur"
><
div
id
="blogdescription"
></
div
></
font
><
br
/>
<
br
/>
<
font
color
="#000066"
><
a
id
="itemlink"
href
="#"
><
div
id
="itemtitle"
></
div
></
a
></
font
><
br
/>
By
<
font
color
="blue"
><
div
id
="author"
></
div
></
font
><
br
/>
<
div
id
="description"
></
div
><
br
/>
<
div
id
="pubDate"
align
="right"
></
div
>
</
body
>
查看全文
相关阅读:
how to use http.Agent in node.js
How Node.js Multiprocess Load Balancing Works
Child Process
What does cmd /C mean? [closed] 关于nodejs的子进程部分
Net
二进制与十六进制的关系
POJ 1201 Intervals (差分约束系统)
POJ 1201 Intervals (差分约束系统)
差分约束系统
差分约束系统
原文地址:https://www.cnblogs.com/zwl12549/p/629224.html
最新文章
索引怎么用
Comet事件分析
Eclipse项目红感叹号
Tomcat开发Comet要点
Comet技术在Java Web中的应用
Comet:基于 HTTP 长连接的“服务器推”技术(转载)
org.apache.log4j与org.apache.commons.logging这两个包有什么区别
Lenovo笔记本Fn的总结
mysql中sql中的注释
Idea中找不到xml配置文件问题研究以及classpath设置(转载)
热门文章
验证思路(转)
simulation clock gen unit (推荐)
clock gate
rom bist scripts
sram bist scripts
memory bist lib
mbist summary
fsm 编码
连接跟踪详解
TCP协议: SYN ACK FIN RST PSH URG 详解
Copyright © 2011-2022 走看看