Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make an "empty" RSS feed

Tags:

php

xml

rss

feed

I'm kind of new to rss feeds, but I'm able to create a feed dynamically using PHP and it works great. My problem is that occasionally the feed doesn't have any items (I limit the age of feed items to 60 days, and sometimes nothing has happened in that time).

What I would expect to happen is that I just simply wouldn't have any <item>s in my xml page. However, when I do it that way, the feed reader (at least the Google one) seems to be a little borked. Even though the XML contains the name of the feed properly still, it shows up without a title.

The only way I've found so far to fix this is to put a dummy item in, that is simply <item><title></title></item>. Then my Google reader finds the name of the feed properly, and it just looks like a blank feed.

It seems that is a hokey solution that is likely incorrect.

Is there some standard way to deal with the XML presentation for an empty feed?

Edit: Here's what the empty feed looks like

<?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>
like image 484
neomech Avatar asked Oct 24 '10 16:10

neomech


People also ask

Is it legal to post RSS feeds on your website?

Unless specific permissions are given to replicate the writing, it is not allowed to be posted on any other website. Only the original website where the content was produced, and the RSS feeds the website sends the content to, fall within the limits of fair use.


1 Answers

A feed with zero items is perfectly valid. If Google Reader doesn't handle that properly it should be reported to them as a bug and they should fix it.

like image 144
Dave Winer Avatar answered Sep 22 '22 12:09

Dave Winer