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.
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:
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.