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!
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.
精彩评论