Create your own RSS

Source: Internet
Author: User

This article mainly provides code to create your own RSS for others' subscriptions...

--- 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>
/// Obtain the aggregated article
/// </Summary>
Public class RSS: System. Web. UI. Page
{
Components. GenRSS gr = new Components. GenRSS (); // instantiate an object

String strRSS = "";

Private void Page_Load (object sender, System. EventArgs e)
{
Response. ContentType = "application/xml"; // output and display according to xml data
Response. Write (GetRSS ());
}

/// <Summary>
/// Obtain the aggregated article
/// </Summary>
Public string GetRSS ()
{
DataSet ds = gr. GenerateRSS (); // call the GenerateRSS () method to obtain data

StrRSS = strRSS + "<rss version = \" 2.0 \ "> ";
StrRSS = strRSS + "<channel> ";
StrRSS = strRSS + "<title> civil manufacturing </title> ";
StrRSS = strRSS + "<link> http://www.socent.com </link> ";
StrRSS = strRSS + "<description> made by people </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> made by people </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;
}

# Code generated by region Web Form Designer
Override protected void OnInit (EventArgs e)
{
//
// CODEGEN: This call is required by the ASP. NET Web form designer.
//
InitializeComponent ();
Base. OnInit (e );
}

/// <Summary>
/// The designer supports the required methods-do not use the code editor to modify
/// Content of this method.
/// </Summary>
Private void InitializeComponent ()
{
This. Load + = new System. EventHandler (this. Page_Load );
}
# Endregion
}
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.