繁体   English   中英

如何制作“空” RSS feed

[英]How to make an “empty” RSS feed

我对rss提要有点陌生,但是我可以使用PHP动态创建一个提要,并且效果很好。 我的问题是,有时Feed中没有任何物品(我将Feed物品的使用期限限制为60天,有时那段时间没有任何反应)。

我希望发生的是,我只是在XML页面中根本没有任何<item> 但是,当我以这种方式执行操作时,供稿阅读器(至少是Google的供稿阅读器)似乎有些乏味。 即使XML仍正确包含提要的名称,它也将显示为没有标题。

到目前为止,我发现解决此问题的唯一方法是放入一个虚拟项目,即<item><title></title></item> 然后,我的Google阅读器正确找到了提要的名称,看起来就像一个空白的提要。

看来这是一个可能不正确的关键解决方案。

是否有一些标准方法来处理空提要的XML表示形式?

编辑:这是空Feed的样子

 <?xml version="1.0" encoding="utf-8"?> <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:content="http://purl.org/rss/1.0/modules/content/"> <channel> <title>News at Example</title> <link>http://www.example.com/feed/sample-reviews</link> <description>Latest Additions to the Sample Category</description> <dc:language>en-us</dc:language> <dc:creator>Contact Example through our "contact us" page</dc:creator> <dc:rights>Copyright 2010 Example Technologies Inc.</dc:rights> <admin:generatorAgent rdf:resource="http://www.codeigniter.com/" /> <item><title></title></item> </channel></rss> 

零项目的Feed完全有效。 如果Google阅读器无法正确处理该问题,则应将其报告为错误,并应予以修复。

空提要是一个没有任何项目的提要附件(通常是XML内容)。 外壳必须仍然有效,才能成为有效的供稿。

RSS 2.0 Specification (2003年起):

频道可以包含任意数量的<item>

但是,从至少一个RSS XSD中,我们可以看到它不受欢迎,并且开发人员也知道:

<xs:element name="item" type="RssItem" minOccurs="1" maxOccurs="unbounded">
         <!-- 
           HACK: According to the RSS 2.0 spec, it should strictly be possible to have zero item elements, 
                 but this makes the schema non-deterministic with regard to extensibility elements
                 so for the moment we undid bug-fix 10231 and set minOccurs=1 to work around this problem. 
         -->
      </xs:element>

在其他客户中尝试您的Feed。 也许这只是google实现的一个怪癖。 YMMV。

快乐的编码。

编辑:有趣的是,看到SO问题: 在哪里可以找到RSS 2.0的官方XSD模式? 这真是令人失望,:-/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM