国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

建立自己的RSS

2024-07-10 13:13:51
字體:
供稿:網(wǎng)友
本文主要提供代碼,創(chuàng)建自己的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數(shù)據(jù)顯示
Response.Write (GetRSS());
}
/// <summary>
/// 取得聚合文章
/// </summary>
public string GetRSS()
{
DataSet ds = gr.GenerateRSS(); // 調(diào)用GenerateRSS()方法,獲得數(shù)據(jù)
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 窗體設(shè)計器生成的代碼
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 該調(diào)用是 ASP.NET Web 窗體設(shè)計器所必需的。
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// 設(shè)計器支持所需的方法 - 不要使用代碼編輯器修改
/// 此方法的內(nèi)容。
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 封开县| 栖霞市| 许昌县| 通化市| 曲阜市| 溆浦县| 湟源县| 剑阁县| 新泰市| 宁乡县| 永德县| 昌黎县| 邳州市| 阜城县| 宁河县| 江华| 左贡县| 楚雄市| 体育| 贵港市| 房山区| 瑞安市| 遵义市| 酉阳| 弋阳县| 剑阁县| 宁陕县| 青海省| 高雄市| 广平县| 峨边| 界首市| 含山县| 循化| 确山县| 中牟县| 务川| 渝北区| 南宫市| 富裕县| 驻马店市|