c# - 如何获取 RSS 提要项目数?

标签 c# .net rss feed

在 C#、.NET 3.5 中,在 Windows 窗体应用程序中...

如何获取给定 RSS url 返回的项目数的整数计数?

例子: 对于我的博客:http://forgefx.blogspot.com/feeds/posts/default

预期结果为:postCount = 25

谢谢!

最佳答案

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();
        }
    }
}

(需要引用 System.ServiceModel.Web.dll)

使用 SyndicationFeed 的一个优点是您可以同时支持 RSS 和 Atom。

关于c# - 如何获取 RSS 提要项目数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3059011/

相关文章:

php - IE 无法显示 Feed,并出现错误 : Internet Explorer does not support feeds with DTDs

php - 使用 PHP 的 Spotify 的 RSS 提要

c# - 图像扭曲和收缩效果,图像失真算法

c# - TreeView.HideSelection = false - WPF 中的等效项

c# - 没有 app.config 的 Entity Framework 代码优先

.net - Azure 表存储中禁止的列名称

php - 从 MySQL 表创建 xml rss 提要时出错

c# - 连接到 Oracle 时出错,TNS :listener does not currently know of service requested in connect descriptor

c# - 枚举可以在 C# 中返回一个新实例吗?

c# - 在 Visual Studio 2012 中调试 .NET Framework 源代码?