風人園

          弱水三千,只取一瓢,便能解渴;佛法無邊,奉行一法,便能得益。
          隨筆 - 99, 文章 - 181, 評論 - 56, 引用 - 0

          導航

          <2025年7月>
          293012345
          6789101112
          13141516171819
          20212223242526
          272829303112
          3456789

          常用鏈接

          留言簿(11)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          新聞檔案

          收藏夾

          友情鏈接

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          asp.net 生成RSS頁面-(zt)

          ?

          ??????????????????????????????????????

          本文主要提供代碼,創建自己的RSS,供別人訂閱...

          ?


          本文主要提供代碼,創建自己的RSS,供別人訂閱...

          --- RSS.aspx

          <%@ Page language="c#" Codebehind="RSS.aspx.cs" AutoEventWireup="false" Inherits="Socent.RSS" %>

          --- RSS.aspx.cs

          using System;
          using System.Collections;
          using System.ComponentModel;
          using System.Data;
          using System.Drawing;
          using System.Web;
          using System.Web.SessionState;
          using System.Web.UI;
          using System.Web.UI.WebControls;
          using System.Web.UI.HtmlControls;

          namespace Socent
          {
          ?/// <summary>
          ?///? 取得聚合文章
          ?/// </summary>
          ?public class RSS : System.Web.UI.Page
          ?{
          ? Components.GenRSS gr = new Components.GenRSS(); // 實例化對象

          ? string strRSS = "";

          ? private void Page_Load(object sender, System.EventArgs e)
          ? {
          ?? Response.ContentType = "application/xml"; // 輸出并按xml數據顯示
          ?? Response.Write (GetRSS());
          ? }

          ? /// <summary>
          ? /// 取得聚合文章
          ? /// </summary>
          ? public string GetRSS()
          ? {?
          ?? DataSet ds = gr.GenerateRSS(); // 調用GenerateRSS()方法,獲得數據

          ?? strRSS = strRSS + "<rss version=\"2.0\">";
          ?? strRSS = strRSS + "<channel>";
          ?? strRSS = strRSS + "<title>土人制造</title>";
          ?? strRSS = strRSS + "<link>http://www.socent.com</link>";
          ?? strRSS = strRSS + "<description>土人制造</description>";
          ?? for(int i = 0; i < ds.Tables[0].Rows.Count; i++)
          ?? {
          ??? strRSS = strRSS + "<item>";
          ??? strRSS = strRSS + "<title><![CDATA["+ds.Tables[0].Rows[i]["Title"]+"]]></title>";
          ??? strRSS = strRSS + "<link>http://www.socent.com/ArticleShow@"+ds.Tables[0].Rows[i]["ID"]+".html</link> ";
          ??? strRSS = strRSS + "<description><![CDATA["+ds.Tables[0].Rows[i]["Description"]+"]]></description>";
          ??? strRSS = strRSS + "<copyright>土人制造</copyright>";
          ??? strRSS = strRSS + "<pubDate>"+Convert.ToDateTime(ds.Tables[0].Rows[i]["AddDate"].ToString()).ToString("yyyy-MM-dd HH:mm")+"</pubDate>";
          ??? strRSS = strRSS + "<comments>http://www.socent.com/CommentShow@"+ds.Tables[0].Rows[i]["ID"]+".html</comments>";
          ??? strRSS = strRSS + "</item>";
          ?? }
          ?? strRSS = strRSS + "</channel>";
          ?? strRSS = strRSS + "</rss>";
          ?
          ?? return strRSS;
          ? }

          ? #region Web 窗體設計器生成的代碼
          ? override protected void OnInit(EventArgs e)
          ? {
          ?? //
          ?? // CODEGEN: 該調用是 ASP.NET Web 窗體設計器所必需的。
          ?? //
          ?? InitializeComponent();
          ?? base.OnInit(e);
          ? }
          ?
          ? /// <summary>
          ? /// 設計器支持所需的方法 - 不要使用代碼編輯器修改
          ? /// 此方法的內容。
          ? /// </summary>
          ? private void InitializeComponent()
          ? {??
          ?? this.Load += new System.EventHandler(this.Page_Load);
          ? }
          ? #endregion
          ?}
          }

          posted on 2006-07-07 10:02 風人園 閱讀(431) 評論(0)  編輯  收藏 所屬分類: DotNet

          主站蜘蛛池模板: 仪征市| 基隆市| 福贡县| 方山县| 承德市| 比如县| 和林格尔县| 新郑市| 江川县| 青海省| 岳池县| 临夏县| 睢宁县| 丰城市| 百色市| 永川市| 宽城| 集安市| 临城县| 东乌珠穆沁旗| 莱西市| 陕西省| 兖州市| 沈丘县| 常山县| 乡宁县| 金塔县| 临沧市| 大安市| 呈贡县| 黑河市| 云阳县| 临猗县| 平度市| 板桥市| 沂南县| 马关县| 大姚县| 五峰| 尉犁县| 胶州市|