How to count the number of RSS feeds?

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

How to get an integer number of items returned by a given url?

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

Expected Result: postCount = 25

Thank!

+3
source share
1 answer
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();
        }
    }
}

(link required System.ServiceModel.Web.dll)

The advantage of using it SyndicationFeedis that you simultaneously support RSS and Atom.

+2
source

Source: https://habr.com/ru/post/1750428/


All Articles