Search code examples
.netrssfeed

Reversing an RSS feed


This could be weird, Have you ever come across a blog which you wanted to read in the chronological order? And that blog could be old, with several hundred posts. When i add this feed to my feed reader, say googlereader, the latest feed comes on top and as i scroll down further, the older posts appear. This could be frustrating if you want to read it from the beginning. Is there any reader that does this? Or, i would love to do this as a pet project, (preferably in c#), how exactly should i go about it? Also, are there any .NET libraries which i can use to work on RSS feeds? I have not done any RSS feed programming before.

EDIT I would like to know if there are any technical limitations to this. This was jsut one interesting problem that I encountered that i thought could be tackled programmatically.


Solution

  • If you do decide to roll your own C# application to do this, it is very straightforward in the current version of the .NET Framework.

    Look for the System.ServiceModel.Syndication namespace. That has classes related to RSS and Atom feeds. I wrote some code recently that generates a feed from a database using these classes, and adds geocodes to the feed items. I had the same problem where i needed to reverse the order of the items in the feed, because my database query returned them in the opposite order I wanted my users to see.

    What I did was to simply hold the list of SyndicationItem objects for the feed in my own List<SyndicationItem> data structure until right before I want to write the feed to disk. Then I would do something like this:

    private SyndicationFeed m_feed;
    private List<SyndicationItem> m_items;
    
    ...snip...
    
    m_items.Reverse();
    m_feed.Items = m_items;