Search code examples
c#rssrss-reader

Get a most recent update of an RSS feed


I'm using C# but this would apply to any other language out there. I found a couple of questions on here that stated an RSS feed will only respond with the last 10 documents but that doesn't seem to be the case on the RSS feeds I'm trying to access.

Example code in C#:

rssXmlDoc.Load("http://sampleRSSfeed.com/rss");
foreach (XmlNode rssNode in rssNodes)
{
     // process rssNode...
}

I can pull the pubDate along with all the other fields.

My problem is that I can't find any way to limit the incoming docs based on date/time of the pubDate. Each call pulls all records which is rather large (hundreds).

Is there a way to request only the documents since the last check?


Solution

  • Unfortunately, you probably can't rely on pubDate because not all feeds will have correct dates in there, and not all feeds have them sorted in reverse chronological order. If you want the most recent, you'll have to fetch the whole feed and keep track of a unique id for each entry (usually the guid element for RSS) and then pull again the feed after a little time and idenity new content. Another option is to use a service like Superfeedr which handles all this for you.