c# - RSS.NET 无法解析 feedburner 提要

标签 c# .net rss feedparser rss.net

我正在为 .NET 2.0 使用 RSS.NET。尽我所能,我得到以下 0 个 channel :

feed = RssFeed.Read("http://feeds.feedburner.com/punchfire?format=xml");

我注意到,对于其他提要,这是有效的,例如

feed = RssFeed.Read("http://www.engadget.com/rss.xml");

我想它必须是有效的 xml 文档。您认为我应该在我的应用程序代码中检查“.xml”还是有什么方法可以调整 RSS.NET 以接受 feedburner 提要?

最佳答案

您无法获得任何 channel 节点的原因是,atom 格式没有任何 channel 节点。检查以下内容

您的第二个链接是一个 Rss Feed,其中包含如下所示的 channel 节点

<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd">
<channel>
<title>Engadget</title>
<link>http://www.engadget.com</link>
 .
 .
 .

另一方面,atom feed 不使用 channel 节点,您可能会通过上面的规范链接理解这一点。

<?xml version="1.0" encoding="utf-8"?>
   <feed xmlns="http://www.w3.org/2005/Atom">
     <title type="text">dive into mark</title>
     <subtitle type="html">
       A &lt;em&gt;lot&lt;/em&gt; of effort
       went into making this effortless
     </subtitle>
     <updated>2005-07-31T12:29:29Z</updated>
     <id>tag:example.org,2003:3</id>
     <link rel="alternate" type="text/html"
      hreflang="en" href="http://example.org/"/>
     <link rel="self" type="application/atom+xml"
      href="http://example.org/feed.atom"/>
     <rights>Copyright (c) 2003, Mark Pilgrim</rights>
     <generator uri="http://www.example.com/" version="1.0">
       Example Toolkit
     </generator>
     <entry>
      .
      .
      .

编辑:检查提要格式

    // url of the feed 
    string utlToload = @"http://feeds.feedburner.com/punchfire?format=xml"



    // load feed
        Argotic.Syndication.GenericSyndicationFeed feed = 
Argotic.Syndication.GenericSyndicationFeed.Create(new Uri(urlToLoad));

        // check what format is it
        if (feed.Format.Equals(SyndicationContentFormat.Rss))
        {
            // yourlogic here
        }
        else if (feed.Format.Equals(SyndicationContentFormat.Atom))
        {
            // yourlogic here
        } 
        else if (feed.Format.Equals(SyndicationContentFormat.NewsML))
        {
            // yourlogic here
        } 

希望对你有帮助

关于c# - RSS.NET 无法解析 feedburner 提要,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2198589/

相关文章:

c# - GridView.Databind() 不适用于对象列表

c# - 为什么密封类不允许作为泛型类型参数?

c# - System.Xml.XmlException - 根元素丢失

xml - 如何使用 XSLT 对 RSS 提要进行分组

c# - Silverlight : Images vs. 向量中的图标

c# - 更新父实体不会更新子实体

c# - 如何从 C# 中的 xml 中读取特定节点?

java - 简单的Web服务认证/授权不是那么简单吗?

java - 尽管设置了用户代理,但来自 Java 应用程序(但不是 Web 浏览器)的 HTTP 403

c# - 如何确定 C# 数据访问层中存储过程输出参数的大小属性