Click here to Skip to main content
13,358,478 members (53,906 online)
Click here to Skip to main content
Add your own
alternative version


55 bookmarked
Posted 5 Oct 2007

Really Simple RSS (Yeah, I know)

, 15 Oct 2007
Rate this:
Please Sign up or sign in to vote.
An easy way to publish your own news feed in ASP.NET


There are plenty of articles out there dealing with consuming RSS, but only a few dealing with making your own. Furthermore, every time I use the xsd.exe tool published by Microsoft, I find people who have never heard of it. Despite its limitations, it is a good tool that needs more mention.

One thing I would like to mention up front is that XML and XSD are usually camelCase and not pascalCase. Unfortunately, the xsd.exe tool generates a blind copy of casing. If you manually edit the generated *.cs file below, you can change the attributes and the casing to get pascalCase .NET code. The output will still be compliant camelCase RSS, i.e.

public partial class RSS {

I don't use this method in this article, in favor of generatability. With that said, I humbly present a simple XSD file and some code which, when used, will make it really simple to add really simple syndication to your site.


This Wikipedia Article on RSS is the best background, I think.


I skipped a lot of the standards for RSS 2.0 to make life easier. If you find you need a field that the schema below doesn't provide, then add it and regenerate the class file. Basically, copy and paste the file below into a file on your machine called C:\RSS_20.xsd (chosen for the article's sake; change at will).

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="" 

    elementFormDefault="unqualified" version="">
        <xs:documentation>Simple XML Schema for RSS 2.0</xs:documentation>
    <xs:element name="rss">
                <xs:element name="channel">
                            <xs:element name="title" type="xs:string" />
                            <xs:element name="link" type="xs:anyURI" />
                            <xs:element name="description" 

                                type="xs:string" />
                            <xs:element name="language" type="xs:string" />
                            <xs:element name="pubDate" type="xs:dateTime" />
                            <xs:element name="lastBuildDate" 

                                type="xs:dateTime" />
                            <xs:element name="docs" type="xs:string" />
                            <xs:element name="generator" type="xs:string" />
                            <xs:element name="managingEditor" 

                                type="xs:string" />
                            <xs:element name="webMaster" type="xs:string" />
                            <xs:element name="item" maxOccurs="unbounded">
                                        <xs:element name="title" 

                                            type="xs:string" />
                                        <xs:element name="link" 

                                            type="xs:string" />
                                        <xs:element name="description" 

                                            type="xs:string" />
                                        <xs:element name="pubDate" 

                                            type="xs:dateTime" />
                                        <xs:element name="guid" 

                                            type="xs:string" />
            <xs:attribute name="version" type="xs:string"/>

Now the fun part. Run a Visual Studio command prompt. There should be a shortcut installed from the Start menu -> Visual Studio -> Visual Studio Tools. If you cannot find it, then just open a command prompt and change your path Environment Variable. While I cannot tell you what your path will be, the one on my current machine is C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727. Your mileage may vary. For those that don't know, the path command is SET PATH=C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin with no space between the equals.

  • In the command prompt, type C: and press Enter
  • In the command prompt, type cd\ and press Enter
  • In the command prompt, type xsd.exe RSS_20.xsd -c /n:"My.Favorite.Namespace" and press Enter

You should now have a RSS_20.cs file created.

// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.832
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>


Add the file to your favorite C# project in ASP.NET. Create a sample page with only the page load method wired up and add the code below.

private rss FakeRss(){
    rss someRss = new rss();
    someRss.version = "2.0"; = new rssChannel(); = "A nice description for the channel"; = "en-us"; = ""; = "The Title of my feed"; = DateTime.Now.ToUniversalTime();

    rssChannelItem channelItem = new rssChannelItem();
    channelItem.pubDate = DateTime.Now.ToUniversalTime();
    channelItem.title = "News Item Title"; = "";
    channelItem.guid = "Usually the link but make it unique";
    channelItem.description = "A Brief Summary"; = new rssChannelItem[]{channelItem};

    return someRss;

protected void Page_Load(object sender, EventArgs e) {
    Response.ContentType = "text/xml";
    Response.ContentEncoding = System.Text.Encoding.UTF8;
    XmlSerializer XML = new XmlSerializer(typeof(rss));
    xml.Serialize(Response.Output, FakeRss());

There you go: an RSS feed that you can deliver from your own site, using a schema which can be validated against illustrating the xsd.exe tool.

Points of Interest


  • 9 October, 2007 -- Removed error in the *.xsd, thanks pzkpfw
  • 5 October, 2007 -- Original version posted


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Ennis Ray Lynch, Jr.
United States United States
My company is ERL GLOBAL, INC. I develop Custom Programming solutions for business of all sizes. I also do Android Programming as I find it a refreshing break from the MS.

You may also be interested in...

Comments and Discussions

QuestionWhy not use a HttpHandler? Pin
Peter Bucher22-Nov-07 9:29
memberPeter Bucher22-Nov-07 9:29 
AnswerRe: Why not use a HttpHandler? Pin
Ennis Ray Lynch, Jr.23-Nov-07 17:24
memberEnnis Ray Lynch, Jr.23-Nov-07 17:24 
GeneralRe: Why not use a HttpHandler? Pin
Peter Bucher23-Nov-07 23:48
memberPeter Bucher23-Nov-07 23:48 
GeneralBookmark pays off - thanks Pin
philmee957-Nov-07 8:04
memberphilmee957-Nov-07 8:04 
QuestionServer Error in '/' Application Pin
Mavusana24-Oct-07 23:09
memberMavusana24-Oct-07 23:09 
AnswerThis may be the wrong forum Pin
Ennis Ray Lynch, Jr.25-Oct-07 4:01
memberEnnis Ray Lynch, Jr.25-Oct-07 4:01 
GeneralNice quick jumpstart Pin
pzkpfw9-Oct-07 11:51
memberpzkpfw9-Oct-07 11:51 
GeneralRofl Pin
Ennis Ray Lynch, Jr.9-Oct-07 12:56
memberEnnis Ray Lynch, Jr.9-Oct-07 12:56 
GeneralLittle Dissapointed Pin
MikJr8-Oct-07 18:03
memberMikJr8-Oct-07 18:03 
GeneralRe: Little Dissapointed Pin
Ennis Ray Lynch, Jr.9-Oct-07 4:39
memberEnnis Ray Lynch, Jr.9-Oct-07 4:39 
GeneralRSS 2.0 Schema Pin
pulsar7-Oct-07 1:50
memberpulsar7-Oct-07 1:50 
GeneralRe: RSS 2.0 Schema Pin
Ennis Ray Lynch, Jr.7-Oct-07 14:53
memberEnnis Ray Lynch, Jr.7-Oct-07 14:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.180111.1 | Last Updated 15 Oct 2007
Article Copyright 2007 by Ennis Ray Lynch, Jr.
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid