Create your own RSS Instance tutorials

Source: Internet
Author: User
Tags cdata
This article mainly provides code to create your own RSS for others to subscribe to ...

---rss.aspx<%@ page language= "C #" codebehind= "RSS.aspx.cs" autoeventwireup= "false" inherits= "Socent.rss"%>--- RSS.aspx.csusing 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:syste  m.web.ui.page {Components.genrss gr = new Components.genrss ();//Instantiation of object string strrss = "";   private void Page_Load (object sender, System.EventArgs e) {Response.ContentType = "application/xml";//output and display as XML data  Response.Write (Getrss ()); }///<summary>///Get aggregated articles///</summary> public string Getrss () {DataSet ds = gr. Generaterss ();   Call the Generaterss () method to get data Strrss = Strrss + "<rss version=\" 2.0\ ">";   Strrss = Strrss + "<channel>";   Strrss = Strrss + "<title> Aborigines manufacturing </title>";Strrss = Strrss + "<link>http://www.socent.com</link>";   Strrss = Strrss + "<description> Aborigines manufacturing </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> Aborigines manufacturing </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 The Web Forms Designer generated code override protected void OnInit (EventArgs e) {/////CODEGEN: This call is required by the ASP.   InitializeComponent (); Base.  OnInit (e);  }//<summary>///designer supports the required method-do not use the Code Editor to modify///The contents 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.