RSS技术实现(asp.net)
PS:改自:http://www.cnblogs.com/ltp/archive/2006/01/15/317725.html
表:
实体类t1.cs,
数据访问和得到实体类 DataAccess.cs
下面是RSS的技术实现代码:
(3) XmlTextWriter实现方式2;Rss.aspx.cs
3.无刷新动态更新的在线RSS阅读获取
表:
实体类t1.cs,
Code
1public class t1
2{
3 public t1()
4 {}
5 Model#region Model
6 private int _tid;
7 private DateTime _tdate;
8 private string _taddname;
9 private string _tcontent;
10 /**//// <summary>
11 ///
12 /// </summary>
13 public int tId
14 {
15 set{ _tid=value;}
16 get{return _tid;}
17 }
18 /**//// <summary>
19 ///
20 /// </summary>
21 public DateTime tDate
22 {
23 set{ _tdate=value;}
24 get{return _tdate;}
25 }
26 /**//// <summary>
27 ///
28 /// </summary>
29 public string tAddname
30 {
31 set{ _taddname=value;}
32 get{return _taddname;}
33 }
34 /**//// <summary>
35 ///
36 /// </summary>
37 public string tContent
38 {
39 set{ _tcontent=value;}
40 get{return _tcontent;}
41 }
42 #endregion Model
43
44}
1public class t1
2{
3 public t1()
4 {}
5 Model#region Model
6 private int _tid;
7 private DateTime _tdate;
8 private string _taddname;
9 private string _tcontent;
10 /**//// <summary>
11 ///
12 /// </summary>
13 public int tId
14 {
15 set{ _tid=value;}
16 get{return _tid;}
17 }
18 /**//// <summary>
19 ///
20 /// </summary>
21 public DateTime tDate
22 {
23 set{ _tdate=value;}
24 get{return _tdate;}
25 }
26 /**//// <summary>
27 ///
28 /// </summary>
29 public string tAddname
30 {
31 set{ _taddname=value;}
32 get{return _taddname;}
33 }
34 /**//// <summary>
35 ///
36 /// </summary>
37 public string tContent
38 {
39 set{ _tcontent=value;}
40 get{return _tcontent;}
41 }
42 #endregion Model
43
44}
数据访问和得到实体类 DataAccess.cs
Code
1public class DataAccess
2{
3 public static DataSet Query(string SQLString)
4 {
5 public static string connectionString = "data source=.;database=test;id=sa;pwd=";
6 using (SqlConnection connection = new SqlConnection(connectionString))
7 {
8 DataSet ds = new DataSet();
9 try
10 {
11 connection.Open();
12 SqlDataAdapter command = new SqlDataAdapter(SQLString, connection);
13 command.Fill(ds, "ds");
14 }
15 catch (System.Data.SqlClient.SqlException ex)
16 {
17 throw new Exception(ex.Message);
18 }
19 return ds;
20 }
21 }
22
23 public DataSet GetList(string strWhere)
24 {
25 StringBuilder strSql=new StringBuilder();
26 strSql.Append("select tId,tDate,tAddname,tContent ");
27 strSql.Append(" FROM t1 ");
28
29 if (strWhere.Trim() != "")
30 {
31 strSql.Append(" where " + strWhere);
32 }
33 return Query(strSql.ToString());
34 }
35}
1public class DataAccess
2{
3 public static DataSet Query(string SQLString)
4 {
5 public static string connectionString = "data source=.;database=test;id=sa;pwd=";
6 using (SqlConnection connection = new SqlConnection(connectionString))
7 {
8 DataSet ds = new DataSet();
9 try
10 {
11 connection.Open();
12 SqlDataAdapter command = new SqlDataAdapter(SQLString, connection);
13 command.Fill(ds, "ds");
14 }
15 catch (System.Data.SqlClient.SqlException ex)
16 {
17 throw new Exception(ex.Message);
18 }
19 return ds;
20 }
21 }
22
23 public DataSet GetList(string strWhere)
24 {
25 StringBuilder strSql=new StringBuilder();
26 strSql.Append("select tId,tDate,tAddname,tContent ");
27 strSql.Append(" FROM t1 ");
28
29 if (strWhere.Trim() != "")
30 {
31 strSql.Append(" where " + strWhere);
32 }
33 return Query(strSql.ToString());
34 }
35}
下面是RSS的技术实现代码:
(1)创建Rss.aspx
<%@ Page language="c#" Codebehind="Rss.aspx.cs" AutoEventWireup="false" Inherits="LiTianPing.Rss" %>
只留下这一行,其余的都删掉。
(2)后台代码;Rss.aspx.cs
Code
1private void Page_Load(object sender, System.EventArgs e)
2{
3 Response.ContentType = "text/xml";
4 Response.Write(GetRSS());
5}
6
7/**//// <summary>
8/// 取得聚合文章
9/// </summary>
10/// <returns></returns>
11public string GetRSS()
12{
13 t1 t = new t1();//自己的业务类
14 cc.Model.t1 t2 = new cc.Model.t1();
15 DataSet ds = t.GetListByClass(1);//根据类别得到数据
16
17
18 StringBuilder strCode = new StringBuilder();
19 strCode.Append("<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>");
20 strCode.Append("<rss version='2.0' xmlns:dc=\"http://purl.org/dc/elements/1.1/\"");
21 strCode.Append(" xmlns:trackback=\"http://madskills.com/public/xml/rss/module/trackback/\" ");
22 strCode.Append(" xmlns:wfw=\"http://wellformedweb.org/CommentAPI/\" xmlns:slash=\"http://purl.org/rss/1.0/modules/slash/\">");
23 strCode.Append("<channel>");
24 strCode.Append("<title>李天平RSSDemo</title>");
25 strCode.Append("<link>http://" + Request.ServerVariables["SERVER_NAME"] + "</link> ");
26 strCode.Append("<description>天道酬勤</description> ");
27 strCode.Append("<copyright>Copyright 2005</copyright> ");
28
29 foreach (DataRow row in ds.Tables[0].Rows)
30 {
31 string Id = row["Id"].ToString();
32 string title = row["title"].ToString();
33 string description = row["description"].ToString();
34 string pubdate = row["pubdate"].ToString();
35 string ClassId = row["ClassId"].ToString();
36 //string author=row["author"].ToString();
37
38 strCode.Append("<item>");
39 strCode.Append("<title>" + title + "</title>");
40 strCode.Append("<link>http://" + Request.ServerVariables["SERVER_NAME"] + "/NewsShow.aspx?ID=" + Id + "</link>");
41 strCode.Append("<subject>" + description + "</subject>");
42 strCode.Append("<description><![CDATA[" + description + "]]></description>");
43 strCode.Append("<PubDate>" + pubdate + "</PubDate>");
44 strCode.Append("<category>" + ClassId + "</category>");
45 strCode.Append("</item>");
46 }
47 strCode.Append("</channel>");
48 strCode.Append("</rss>");
49 return strCode.ToString();
50}
1private void Page_Load(object sender, System.EventArgs e)
2{
3 Response.ContentType = "text/xml";
4 Response.Write(GetRSS());
5}
6
7/**//// <summary>
8/// 取得聚合文章
9/// </summary>
10/// <returns></returns>
11public string GetRSS()
12{
13 t1 t = new t1();//自己的业务类
14 cc.Model.t1 t2 = new cc.Model.t1();
15 DataSet ds = t.GetListByClass(1);//根据类别得到数据
16
17
18 StringBuilder strCode = new StringBuilder();
19 strCode.Append("<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>");
20 strCode.Append("<rss version='2.0' xmlns:dc=\"http://purl.org/dc/elements/1.1/\"");
21 strCode.Append(" xmlns:trackback=\"http://madskills.com/public/xml/rss/module/trackback/\" ");
22 strCode.Append(" xmlns:wfw=\"http://wellformedweb.org/CommentAPI/\" xmlns:slash=\"http://purl.org/rss/1.0/modules/slash/\">");
23 strCode.Append("<channel>");
24 strCode.Append("<title>李天平RSSDemo</title>");
25 strCode.Append("<link>http://" + Request.ServerVariables["SERVER_NAME"] + "</link> ");
26 strCode.Append("<description>天道酬勤</description> ");
27 strCode.Append("<copyright>Copyright 2005</copyright> ");
28
29 foreach (DataRow row in ds.Tables[0].Rows)
30 {
31 string Id = row["Id"].ToString();
32 string title = row["title"].ToString();
33 string description = row["description"].ToString();
34 string pubdate = row["pubdate"].ToString();
35 string ClassId = row["ClassId"].ToString();
36 //string author=row["author"].ToString();
37
38 strCode.Append("<item>");
39 strCode.Append("<title>" + title + "</title>");
40 strCode.Append("<link>http://" + Request.ServerVariables["SERVER_NAME"] + "/NewsShow.aspx?ID=" + Id + "</link>");
41 strCode.Append("<subject>" + description + "</subject>");
42 strCode.Append("<description><![CDATA[" + description + "]]></description>");
43 strCode.Append("<PubDate>" + pubdate + "</PubDate>");
44 strCode.Append("<category>" + ClassId + "</category>");
45 strCode.Append("</item>");
46 }
47 strCode.Append("</channel>");
48 strCode.Append("</rss>");
49 return strCode.ToString();
50}
(3) XmlTextWriter实现方式2;Rss.aspx.cs
Code
1//XmlTextWriter实现方式2
2
3string xmlDoc = "rss.xml";
4private void Page_Load(object sender, System.EventArgs e)
5{
6 xmlDoc = Server.MapPath(".") + xmlDoc;
7 GetRSS2();
8 XmlDocument doc = new XmlDocument();
9 doc.Load(xmlDoc);
10 Response.ContentType = "text/xml";
11 doc.Save(Response.Output);
12}
13/**//// <summary>
14/// 取得聚合文章
15/// </summary>
16/// <returns></returns>
17public void GetRSS2()
18{
19 //News t = new News();
20 //DataSet ds = t.GetListByClass(1);
21
22 cc.BLL.t1 test = new t1();
23 DataSet ds = test.GetList("");
24
25 XmlTextWriter writer = new XmlTextWriter(xmlDoc, Encoding.UTF8);
26 writer.Formatting = Formatting.Indented;
27 writer.WriteStartDocument(true);
28 writer.WriteComment("RSS页的实现");
29 writer.WriteStartElement("rss");
30 writer.WriteAttributeString("version", "2.0");
31 writer.WriteStartElement("channel");
32 writer.WriteStartElement("title");
33 writer.WriteString("李天平RSSDemo");
34 writer.WriteEndElement();
35 writer.WriteStartElement("link");
36 writer.WriteString("http://" + Request.ServerVariables["SERVER_NAME"]);
37 writer.WriteEndElement();
38 writer.WriteStartElement("description");
39 writer.WriteString("天道酬勤");
40 writer.WriteEndElement();
41 writer.WriteStartElement("copyright");
42 writer.WriteString("Copyright 2005");
43 writer.WriteEndElement();
44 writer.WriteStartElement("language");
45 writer.WriteString("zh-cn");
46 writer.WriteEndElement();
47
48 foreach (DataRow row in ds.Tables[0].Rows)
49 {
50 string Id = row["tId"].ToString();
51 string title = row["tDate"].ToString();
52 string description = row["tAddname"].ToString();
53 string pubdate = row["tContent"].ToString();
54 //string ClassId = row["ClassId"].ToString();
55 //string author=row["author"].ToString();
56
57
58 writer.WriteStartElement("item");
59 writer.WriteStartElement("title");
60 writer.WriteString(title);
61 writer.WriteEndElement();
62 writer.WriteStartElement("link");
63 writer.WriteString("http://" + Request.ServerVariables["SERVER_NAME"] + "/NewsShow.aspx?ID=" + Id);
64 writer.WriteEndElement();
65 writer.WriteStartElement("description");
66 writer.WriteCData(description);
67 writer.WriteEndElement();
68 writer.WriteStartElement("pubDate");
69 writer.WriteString(pubdate);
70 writer.WriteEndElement();
71 //writer.WriteStartElement("category");
72 //writer.WriteString(ClassId);
73 //writer.WriteEndElement();
74 writer.WriteEndElement();
75 }
76 writer.WriteEndElement();
77 writer.WriteEndElement();
78 writer.Flush();
79 writer.Close();
80
81}
1//XmlTextWriter实现方式2
2
3string xmlDoc = "rss.xml";
4private void Page_Load(object sender, System.EventArgs e)
5{
6 xmlDoc = Server.MapPath(".") + xmlDoc;
7 GetRSS2();
8 XmlDocument doc = new XmlDocument();
9 doc.Load(xmlDoc);
10 Response.ContentType = "text/xml";
11 doc.Save(Response.Output);
12}
13/**//// <summary>
14/// 取得聚合文章
15/// </summary>
16/// <returns></returns>
17public void GetRSS2()
18{
19 //News t = new News();
20 //DataSet ds = t.GetListByClass(1);
21
22 cc.BLL.t1 test = new t1();
23 DataSet ds = test.GetList("");
24
25 XmlTextWriter writer = new XmlTextWriter(xmlDoc, Encoding.UTF8);
26 writer.Formatting = Formatting.Indented;
27 writer.WriteStartDocument(true);
28 writer.WriteComment("RSS页的实现");
29 writer.WriteStartElement("rss");
30 writer.WriteAttributeString("version", "2.0");
31 writer.WriteStartElement("channel");
32 writer.WriteStartElement("title");
33 writer.WriteString("李天平RSSDemo");
34 writer.WriteEndElement();
35 writer.WriteStartElement("link");
36 writer.WriteString("http://" + Request.ServerVariables["SERVER_NAME"]);
37 writer.WriteEndElement();
38 writer.WriteStartElement("description");
39 writer.WriteString("天道酬勤");
40 writer.WriteEndElement();
41 writer.WriteStartElement("copyright");
42 writer.WriteString("Copyright 2005");
43 writer.WriteEndElement();
44 writer.WriteStartElement("language");
45 writer.WriteString("zh-cn");
46 writer.WriteEndElement();
47
48 foreach (DataRow row in ds.Tables[0].Rows)
49 {
50 string Id = row["tId"].ToString();
51 string title = row["tDate"].ToString();
52 string description = row["tAddname"].ToString();
53 string pubdate = row["tContent"].ToString();
54 //string ClassId = row["ClassId"].ToString();
55 //string author=row["author"].ToString();
56
57
58 writer.WriteStartElement("item");
59 writer.WriteStartElement("title");
60 writer.WriteString(title);
61 writer.WriteEndElement();
62 writer.WriteStartElement("link");
63 writer.WriteString("http://" + Request.ServerVariables["SERVER_NAME"] + "/NewsShow.aspx?ID=" + Id);
64 writer.WriteEndElement();
65 writer.WriteStartElement("description");
66 writer.WriteCData(description);
67 writer.WriteEndElement();
68 writer.WriteStartElement("pubDate");
69 writer.WriteString(pubdate);
70 writer.WriteEndElement();
71 //writer.WriteStartElement("category");
72 //writer.WriteString(ClassId);
73 //writer.WriteEndElement();
74 writer.WriteEndElement();
75 }
76 writer.WriteEndElement();
77 writer.WriteEndElement();
78 writer.Flush();
79 writer.Close();
80
81}
Code
12.在线RSS阅读获取。
2
3页面代码:
4 <P style="FONT-SIZE: 11px">
5 Feed种子:<asp:TextBox id="FeedUrl" runat="server" Width="440px"></asp:TextBox><BR>
6 显示条数:<asp:TextBox id="Num" runat="server" Width="48px"></asp:TextBox></P>
7 <P style="FONT-SIZE: 11px">
8 <asp:Button id="GetFeed" runat="server" Text="获得RSS"></asp:Button><BR>
9 <BR>
10 <asp:Label id="RssFeed" runat="server"></asp:Label></P>
11
12后台代码:
13 /**//// <summary>
14 /// 获得要显示的Feed种子数据
15 /// </summary>
16 /// <param name="RssUrl"></param>
17 /// <param name="showNewsCount"></param>
18 /// <returns></returns>
19 public string LoadRSS(string RssUrl, int showNewsCount)
20 {
21 string strRssList = "";
22 string strMsg;
23 try
24 {
25 XmlDocument objXMLDoc = new XmlDocument();
26 objXMLDoc.Load(RssUrl);
27 XmlNodeList objItems = objXMLDoc.GetElementsByTagName("item");
28
29 if(showNewsCount > 30)
30 showNewsCount = 10;
31 if(showNewsCount < 1)
32 showNewsCount = objItems.Count;
33
34 string title="";
35 string link="";
36 int i;
37
38 if(objXMLDoc.HasChildNodes == true)
39 {
40 i = 1;
41 foreach(XmlNode objNode in objItems)
42 {
43 if(i<=showNewsCount)
44 {
45 if(objNode.HasChildNodes == true)
46 {
47 XmlNodeList objItemsChild = objNode.ChildNodes;
48 foreach(XmlNode objNodeChild in objItemsChild)
49 {
50 switch(objNodeChild.Name)
51 {
52 case "title":
53 title = objNodeChild.InnerText;
54 break;
55 case "link":
56 link = objNodeChild.InnerText;
57 break;
58 }
59 }
60 i = i+1;
61 strRssList += "<a href=" + link +" target=_blank>" + title + "</a><br>";
62 }
63 }
64 }
65 }
66 strMsg = strRssList;
67 }
68 catch
69 {
70 strMsg = "RSS Feed 源数据出错!";
71 }
72 return strMsg;
73 }
74
75 //获取按钮,获取指定RSS
76 private void GetFeed_Click(object sender, System.EventArgs e)
77 {
78 if(FeedUrl.Text == "")//RSS地址
79 {
80 RssFeed.Text = "信息源不能为空,您可刷新重试或联系管理员!";
81 return ;
82 }
83 RssFeed.Text = LoadRSS(FeedUrl.Text,Convert.ToInt32(Num.Text)); //获取指定数目
84 }
12.在线RSS阅读获取。
2
3页面代码:
4 <P style="FONT-SIZE: 11px">
5 Feed种子:<asp:TextBox id="FeedUrl" runat="server" Width="440px"></asp:TextBox><BR>
6 显示条数:<asp:TextBox id="Num" runat="server" Width="48px"></asp:TextBox></P>
7 <P style="FONT-SIZE: 11px">
8 <asp:Button id="GetFeed" runat="server" Text="获得RSS"></asp:Button><BR>
9 <BR>
10 <asp:Label id="RssFeed" runat="server"></asp:Label></P>
11
12后台代码:
13 /**//// <summary>
14 /// 获得要显示的Feed种子数据
15 /// </summary>
16 /// <param name="RssUrl"></param>
17 /// <param name="showNewsCount"></param>
18 /// <returns></returns>
19 public string LoadRSS(string RssUrl, int showNewsCount)
20 {
21 string strRssList = "";
22 string strMsg;
23 try
24 {
25 XmlDocument objXMLDoc = new XmlDocument();
26 objXMLDoc.Load(RssUrl);
27 XmlNodeList objItems = objXMLDoc.GetElementsByTagName("item");
28
29 if(showNewsCount > 30)
30 showNewsCount = 10;
31 if(showNewsCount < 1)
32 showNewsCount = objItems.Count;
33
34 string title="";
35 string link="";
36 int i;
37
38 if(objXMLDoc.HasChildNodes == true)
39 {
40 i = 1;
41 foreach(XmlNode objNode in objItems)
42 {
43 if(i<=showNewsCount)
44 {
45 if(objNode.HasChildNodes == true)
46 {
47 XmlNodeList objItemsChild = objNode.ChildNodes;
48 foreach(XmlNode objNodeChild in objItemsChild)
49 {
50 switch(objNodeChild.Name)
51 {
52 case "title":
53 title = objNodeChild.InnerText;
54 break;
55 case "link":
56 link = objNodeChild.InnerText;
57 break;
58 }
59 }
60 i = i+1;
61 strRssList += "<a href=" + link +" target=_blank>" + title + "</a><br>";
62 }
63 }
64 }
65 }
66 strMsg = strRssList;
67 }
68 catch
69 {
70 strMsg = "RSS Feed 源数据出错!";
71 }
72 return strMsg;
73 }
74
75 //获取按钮,获取指定RSS
76 private void GetFeed_Click(object sender, System.EventArgs e)
77 {
78 if(FeedUrl.Text == "")//RSS地址
79 {
80 RssFeed.Text = "信息源不能为空,您可刷新重试或联系管理员!";
81 return ;
82 }
83 RssFeed.Text = LoadRSS(FeedUrl.Text,Convert.ToInt32(Num.Text)); //获取指定数目
84 }
3.无刷新动态更新的在线RSS阅读获取
Code
1<%@ Page language="c#" Codebehind="XmlHttp.aspx.cs" AutoEventWireup="false" Inherits="LiTianPing.XmlHttp" %>
2<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
3<HTML>
4 <HEAD>
5 <title>XmlHttp</title>
6 <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
7 <meta name="CODE_LANGUAGE" Content="C#">
8 <meta name="vs_defaultClientScript" content="JavaScript">
9 <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
10 <style>td {}{ font-size: 9pt}
11 </style>
12 <script>
13 <!--
14 var oDiv
15 var xh
16 function getXML()
17 {
18 xh =new ActiveXObject("Microsoft.XMLHTTP");
19 oDiv = document.getElementById("rssitem");
20 oDiv.style.display= "";
21 try
22 {
23 //如果是本地改成下面语句直接读取
24 //xh.open("GET","/Rss.aspx",false);
25 xh.open("GET","Http://ltp.cnblogs.com/Rss.aspx",false);
26 xh.send(null);
27 loadData(xh,oDiv);
28 }
29 catch(e)
30 {
31 error(oDiv);
32 }
33 }
34 function loadData(xh,oDiv)
35 {
36 if (xh.readyState == 4)
37 {
38 xml = xh.responsexml;
39 var i;
40 var nodes = xml.selectNodes("/rss/channel/item");
41 var bloglink = xml.selectSingleNode("/rss/channel/link").text;
42 oDiv.innerHTML = "";
43 var html;
44 for(i=0;i<nodes.length;i++)
45 {
46
47 html += "<div >";
48 html += " <div >";
49 html += " <a class=font1 href='" +nodes[i].selectSingleNode("link").text + "' target='_blank'>" + nodes[i].selectSingleNode("title").text +"</a><BR><BR>";
50 html += " </div>";
51 html += " <div >";
52 html += " " +nodes[i].selectSingleNode("description").text;
53 html += " </div>"
54 //html += " </div>";
55 html += "</div><hr>";
56
57 }
58 oDiv.innerHTML = html;
59 }
60 else
61 {
62 error(oDiv);
63 }
64 }
65
66 function error(oDiv)
67 {
68 oDiv.innerHTML = "载入失败";
69 }
70 -->
71 </script>
72 </HEAD>
73 <body MS_POSITIONING="GridLayout" onload="window.setTimeout('getXML()',200);">
74 <form id="Form1" method="post" runat="server">
75 <div align=center>
76 <table cellpadding="0" cellspacing="0" border="0" width="80%">
77 <tr>
78 <td>
79 <div id="rssitem" style="WIDTH:80%">数据载入中</div>
80 </td>
81 </tr>
82 </table>
83 </div>
84 </form>
85 </body>
86</HTML>
1<%@ Page language="c#" Codebehind="XmlHttp.aspx.cs" AutoEventWireup="false" Inherits="LiTianPing.XmlHttp" %>
2<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
3<HTML>
4 <HEAD>
5 <title>XmlHttp</title>
6 <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
7 <meta name="CODE_LANGUAGE" Content="C#">
8 <meta name="vs_defaultClientScript" content="JavaScript">
9 <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
10 <style>td {}{ font-size: 9pt}
11 </style>
12 <script>
13 <!--
14 var oDiv
15 var xh
16 function getXML()
17 {
18 xh =new ActiveXObject("Microsoft.XMLHTTP");
19 oDiv = document.getElementById("rssitem");
20 oDiv.style.display= "";
21 try
22 {
23 //如果是本地改成下面语句直接读取
24 //xh.open("GET","/Rss.aspx",false);
25 xh.open("GET","Http://ltp.cnblogs.com/Rss.aspx",false);
26 xh.send(null);
27 loadData(xh,oDiv);
28 }
29 catch(e)
30 {
31 error(oDiv);
32 }
33 }
34 function loadData(xh,oDiv)
35 {
36 if (xh.readyState == 4)
37 {
38 xml = xh.responsexml;
39 var i;
40 var nodes = xml.selectNodes("/rss/channel/item");
41 var bloglink = xml.selectSingleNode("/rss/channel/link").text;
42 oDiv.innerHTML = "";
43 var html;
44 for(i=0;i<nodes.length;i++)
45 {
46
47 html += "<div >";
48 html += " <div >";
49 html += " <a class=font1 href='" +nodes[i].selectSingleNode("link").text + "' target='_blank'>" + nodes[i].selectSingleNode("title").text +"</a><BR><BR>";
50 html += " </div>";
51 html += " <div >";
52 html += " " +nodes[i].selectSingleNode("description").text;
53 html += " </div>"
54 //html += " </div>";
55 html += "</div><hr>";
56
57 }
58 oDiv.innerHTML = html;
59 }
60 else
61 {
62 error(oDiv);
63 }
64 }
65
66 function error(oDiv)
67 {
68 oDiv.innerHTML = "载入失败";
69 }
70 -->
71 </script>
72 </HEAD>
73 <body MS_POSITIONING="GridLayout" onload="window.setTimeout('getXML()',200);">
74 <form id="Form1" method="post" runat="server">
75 <div align=center>
76 <table cellpadding="0" cellspacing="0" border="0" width="80%">
77 <tr>
78 <td>
79 <div id="rssitem" style="WIDTH:80%">数据载入中</div>
80 </td>
81 </tr>
82 </table>
83 </div>
84 </form>
85 </body>
86</HTML>