网络编程 
首页 > 网络编程 > 浏览文章

建立自己的RSS

(编辑:jimmy 日期: 2024/5/9 浏览:3 次 )

本文主要提供代码,创建自己的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
"";

  private void Page_Load(object sender, System.EventArgs e)
  "application/xml"; // 输出并按xml数据显示
   Response.Write (GetRSS());
  "<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++)
   "<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>";
   "</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
 }
}

上一篇:Asp.net中处理一个站点不同Web应用共享Session的问题
下一篇:DataGrid同时具有分页和排序功能及注意点
一句话新闻
高通与谷歌联手!首款骁龙PC优化Chrome浏览器发布
高通和谷歌日前宣布,推出首次面向搭载骁龙的Windows PC的优化版Chrome浏览器。
在对骁龙X Elite参考设计的初步测试中,全新的Chrome浏览器在Speedometer 2.1基准测试中实现了显著的性能提升。
预计在2024年年中之前,搭载骁龙X Elite计算平台的PC将面世。该浏览器的提前问世,有助于骁龙PC问世就获得满血表现。
谷歌高级副总裁Hiroshi Lockheimer表示,此次与高通的合作将有助于确保Chrome用户在当前ARM兼容的PC上获得最佳的浏览体验。
友情链接:杰晶网络 DDR爱好者之家 南强小屋 黑松山资源网 白云城资源网