2.4 Serving RSS

Serving an RSS feed is simple. By far, the most common way to serve RSS is to use an ordinary web server. The feed is treated as any other text document and requested and delivered over HTTP.

Setting the Correct MIME Types

Whatever file extension you choose for your RSS feed (and although there is no standard, the RSS 1.0 specification suggests either .xml or .rdf ), you should set up your server to deliver the correct MIME type with the file. At the time of this writing, there are efforts being made to create an RSS-specific MIME type. Consult the online development lists for the latest news, but in the meantime you should be using application/rss+xml .

For Apache, this is done by adding the following line to the httpd.conf file:

 AddType application/rss+xml .rdf .xml 

RSS, however, does not prescribe the transport mechanism. Feeds can be delivered over anything from FTP to Jabber, the XML-based messaging platform.

2.4.1 Consuming the Feed

For a standard that started out as an add-on to a simple portal web page, RSS has come a long way in terms of user clients . RSS feeds are still being used for web page creation, but they are also being wired into desktop newsreaders, search engines, instant messaging services, and content systems for mobile phone-based services, such as the Short Message Service (SMS).

Whatever the client, the feed is requested and retrieved over the transport method of choice and delivered to a parser. RSS parsers come in various flavors: from the full-on XML parsers, down to the RSS-specific quick-and-dirty versions (perhaps in a scripting language such as Perl) that rely on regular expressions to filter the content.

This is not the book to explain the actual parsing process in theory, and we should leave the practice to later chapters, but it will suffice to say that there are two ways of doing it:

Straightforward parsing

Taking values from within elements and applying them somewhere else. In this way you can build other documents, or you can apply the data within other applications.


Using XSLT to transform the RSS into another flavor of XML XHTML, for example.

Chapter 1 and Chapter 2 have provided a general overview of content syndication with RSS. In Chapter 3, we'll look at the different feed standards in more detail.

Content Syndication with RSS
Content Syndication with RSS
ISBN: 0596003838
EAN: 2147483647
Year: 2005
Pages: 96

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net