本文主要提供代码,创建自己的RSS,供别人订阅...

RSS.aspx

建立自己的RSS<%@ Page language="c#" Codebehind="RSS.aspx.cs" AutoEventWireup="false" Inherits="Socent.RSS" %>
建立自己的RSS
建立自己的RSSRSS.aspx.cs
建立自己的RSS
建立自己的RSS
using System;
建立自己的RSS
using System.Collections;
建立自己的RSS
using System.ComponentModel;
建立自己的RSS
using System.Data;
建立自己的RSS
using System.Drawing;
建立自己的RSS
using System.Web;
建立自己的RSS
using System.Web.SessionState;
建立自己的RSS
using System.Web.UI;
建立自己的RSS
using System.Web.UI.WebControls;
建立自己的RSS
using System.Web.UI.HtmlControls;
建立自己的RSS
建立自己的RSS
namespace Socent
{

建立自己的RSS 
///  取得聚合文章
建立自己的RSS 
/// </summary>
建立自己的RSS public class RSS : System.Web.UI.Page
{
建立自己的RSS  Components.GenRSS gr 
= new Components.GenRSS(); // 实例化对象
建立自己的RSS

建立自己的RSS  
string strRSS = "";
建立自己的RSS
建立自己的RSS  
private void Page_Load(object sender, System.EventArgs e)
{
建立自己的RSS   Response.ContentType 
= "application/xml"// 输出并按xml数据显示
建立自己的RSS
   Response.Write (GetRSS());
建立自己的RSS  }

建立自己的RSS

建立自己的RSS  
/// 取得聚合文章
建立自己的RSS  
/// </summary>
建立自己的RSS  public string GetRSS()
{   
建立自己的RSS   DataSet ds 
= gr.GenerateRSS(); // 调用GenerateRSS()方法,获得数据
建立自己的RSS

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

建立自己的RSS   strRSS 
= strRSS + "</channel>";
建立自己的RSS   strRSS 
= strRSS + "</rss>";
建立自己的RSS   
建立自己的RSS   
return strRSS;
建立自己的RSS  }

建立自己的RSS

建立自己的RSS  
override protected void OnInit(EventArgs e)
{
建立自己的RSS   
//
建立自己的RSS   
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
建立自己的RSS   
//
建立自己的RSS
   InitializeComponent();
建立自己的RSS   
base.OnInit(e);
建立自己的RSS  }

建立自己的RSS  

建立自己的RSS  
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
建立自己的RSS  
/// 此方法的内容。
建立自己的RSS  
/// </summary>
建立自己的RSS  private void InitializeComponent()
{    
建立自己的RSS   
this.Load += new System.EventHandler(this.Page_Load);
建立自己的RSS  }

建立自己的RSS  
#endregion
建立自己的RSS }

建立自己的RSS}
转自:http://goaler.xicp.net/Article/ShowArticle.asp?ID=558

相关文章: