<!
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" >
< html xmlns ="http://www.w3.org/1999/xhtml" >
< head >
< title > RSS Reader </ title >
< script type ="text/javascript" >
var xmlHttp;
function showRSS(){
var target=document.getElementById("targeturl");
readRSS(target.value);
}
function createXMLHttpReques()
{
if(window.ActiiveXObject)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHttp");
else if(window.XMLHttpRequest)
{
xmlHttp=new XMLHttpRequest();
}
}
}
function readRSS(url)
{
createXMLHttpRequest();
xmlHttp.onreadystatechange=handleStateChange;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
function handleStateChange() {
if(xmlHttp.readyState == 4) {
if(xmlHttp.status == 200) {
clearPreviousResults();
parseResults();
}
}
}
function clearPreviousResults() {
var ListBody = document.getElementById("resultsTitle");
while(ListBody.childNodes.length > 0) {
ListBody.removeChild(ListBody.childNodes[0]);
}
}
function parseResults() {
var results = xmlHttp.responseXML;
var title = null;
var content=null;
var item = null;
var items = results.getElementsByTagName("item");
for(var i = 0; i < items.length; i++) {
item = items[i];
title = item.getElementsByTagName("title")[0].firstChild.nodeValue;
content=item.getElementsByTagName("description")[0].firstChild.nodeValue;
addListRow(title,content);
}
}
function addListRow(title,content) {
var row = document.createElement("ul");
var cell = createCellWithText(title);
var contentcell=createCellWithContent(content);
row.appendChild(cell);
row.appendChild(contentcell);
document.getElementById("resultsTitle").appendChild(row);
}
function createCellWithText(text) {
var cell = document.createElement("li");
var textNode = document.createTextNode(text);
cell.appendChild(textNode);
return cell;
}
function createCellWithContent(content) {
var cell=document.createElement("h1")
var textNode = document.createTextNode(content);
cell.appendChild(textNode);
return cell;
}
</ script >
</ head >
< body >
< h2 > Blog文章列表 </ h2 >
< input type ="text" id ="targeturl" name ="textfield" />
< input type ="button" value ="搜索" onclick ="ShowRSS();" />
< div id ="resultsTitle" >
</ div >
</ body >
</ html >
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" >
< html xmlns ="http://www.w3.org/1999/xhtml" >
< head >
< title > RSS Reader </ title >
< script type ="text/javascript" >
var xmlHttp;
function showRSS(){
var target=document.getElementById("targeturl");
readRSS(target.value);
}
function createXMLHttpReques()
{
if(window.ActiiveXObject)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHttp");
else if(window.XMLHttpRequest)
{
xmlHttp=new XMLHttpRequest();
}
}
}
function readRSS(url)
{
createXMLHttpRequest();
xmlHttp.onreadystatechange=handleStateChange;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
function handleStateChange() {
if(xmlHttp.readyState == 4) {
if(xmlHttp.status == 200) {
clearPreviousResults();
parseResults();
}
}
}
function clearPreviousResults() {
var ListBody = document.getElementById("resultsTitle");
while(ListBody.childNodes.length > 0) {
ListBody.removeChild(ListBody.childNodes[0]);
}
}
function parseResults() {
var results = xmlHttp.responseXML;
var title = null;
var content=null;
var item = null;
var items = results.getElementsByTagName("item");
for(var i = 0; i < items.length; i++) {
item = items[i];
title = item.getElementsByTagName("title")[0].firstChild.nodeValue;
content=item.getElementsByTagName("description")[0].firstChild.nodeValue;
addListRow(title,content);
}
}
function addListRow(title,content) {
var row = document.createElement("ul");
var cell = createCellWithText(title);
var contentcell=createCellWithContent(content);
row.appendChild(cell);
row.appendChild(contentcell);
document.getElementById("resultsTitle").appendChild(row);
}
function createCellWithText(text) {
var cell = document.createElement("li");
var textNode = document.createTextNode(text);
cell.appendChild(textNode);
return cell;
}
function createCellWithContent(content) {
var cell=document.createElement("h1")
var textNode = document.createTextNode(content);
cell.appendChild(textNode);
return cell;
}
</ script >
</ head >
< body >
< h2 > Blog文章列表 </ h2 >
< input type ="text" id ="targeturl" name ="textfield" />
< input type ="button" value ="搜索" onclick ="ShowRSS();" />
< div id ="resultsTitle" >
</ div >
</ body >
</ html >