MS Syndication类不接受有效的RSS提要

时间:2013-01-18 13:55:01

标签: c# .net rss

为什么MS Syndication类不接受有效的RSS提要?

public static Stream GetResponseStream(string url)
{
    var uri = new Uri(url, true);
    WebRequest request = WebRequest.Create(uri);
    request.Method = WebRequestMethods.Http.Get;
    WebResponse response = request.GetResponse();
    return response.GetResponseStream();
}

public static void GetRSS()
{
    using (Stream stream1 = GetResponseStream("http://www.lostfilm.tv/rssdd.xml"))
    {
        try
        {
            XmlReader xmlReader = XmlReader.Create(stream1);
            var feeds = SyndicationFeed.Load(xmlReader);
        }
        catch (Exception ex)
        {
            // Error :( 
        }
    }
}

RSS本身就是有效的:

http://validator.w3.org/appc/check.cgi?url=http%3A%2F%2Fwww.lostfilm.tv%2Frssdd.xml

1 个答案:

答案 0 :(得分:1)

SyndicationFeed仅支持RSS 2.0和Atom 1.0(您的RSS版本为0.91)。

您可以使用外部库,例如Argotic Syndication Framework

使用NuGet安装包:

Install-Package Argotic.Core

然后尝试:

var feed = RssFeed.Create(new Uri("http://www.lostfilm.tv/rssdd.xml", true));
foreach (var post in feed.Channel.Items)
{
    Console.WriteLine(post.Title);
}