2010-06-17 52 views

回答

2
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在同一时间。

+0

我怀疑这会起作用。如果源代码实现分页,那么只会得到页面大小。 – 2016-10-11 13:42:19

+0

因为[SyndicationFeed.Items](https://msdn.microsoft.com/en-us/library/system.servicemodel.syndication.syndicationfeed.items.aspx)返回一个'IEnumerable '而不是'收藏品'。 – 2017-01-31 20:54:03