How to store our news items according to RSS2.0 specifications, we first create an ASP. NET page, when a user sends a request, it will return the aggregated content of the website. More specifically, we will create an ASP. NET page named rss. aspx, which will return the latest five news items in the Articles database table in the format specified by RSS2.0.
There are several ways to accomplish this, which will be discussed later. But now, we need to do one thing first, that is, we need to get the latest five news items from the database. This can be obtained using the following SQL query statement:
SELECTTOP5ArticleID, Title, Author, Description, DatePublishedFROMArticlesORDERBYDatePublishedDESC
After obtaining the information, we need to convert the information into the corresponding RSS2.0 format aggregate file. The easiest and quickest way to display database data as XML data is to use the Repeater control. To be precise, the Repeater control displays <rss> elements, <channel> elements, and site-related element tags in HeaderTemplate and FooterTemplate templates, and <item> elements in ItemTemplate templates. Below is the HTML section of the ASP. NET page. aspx file:
- <%@Pagelanguage="c#"ContentType="text/xml"Codebehind="rss.aspx.cs"
- AutoEventWireup="false"Inherits="SyndicationDemo.rss"%>
- <asp:Repeateridasp:Repeaterid="rptRSS"runat="server">
- <HeaderTemplate>
- <rssversionrssversion="2.0">
- <channel>
- <title>ASP.NETNews!</title>
- <li>
- XML data displayed on the ASP. NET page
- What is iframe asp. NET?
- ASP. NET lifecycle display
- Solve the Problem of ASP. net ajax script errors
- ASP. NET Applications