tags:

views:

42

answers:

1

Hello,

In C#, .NET 3.5, in a Windows Forms application...

How does one get the integer count of the number of items that a given RSS url returns?

Example: For my blog at: http://forgefx.blogspot.com/feeds/posts/default

The expected result would be: postCount = 25

Thanks!

+1  A: 
using System.ServiceModel.Syndication;
using System.Linq;
class Program
{
    static void Main()
    {
        using(XmlReader source = XmlReader.Create(
                 "http://forgefx.blogspot.com/feeds/posts/default")) {
            int count = SyndicationFeed.Load(source).Items.Count();
        }
    }
}

(requires a reference to System.ServiceModel.Web.dll)

An advantage of using SyndicationFeed is that you support RSS and Atom at the same time.

Marc Gravell