Logo         Community
The Company
Your Account
Contact Us
PHP 101 (part 15): No News is Good News
Build your own personal RSS aggregator with PHP, SimpleXML and SQLite

| Alphabet Soup |

I'll start with the basics. What the heck is RSS anyhow?

RSS (the acronym stands for RDF Site Summary) is a format originally devised by Netscape to distribute information about the content on its My.Netscape.Com portal. The format has gone through many iterations since its introduction in early 1997 (take a look at http://backend.userland.com/stories/rss091 for information on RSS's long and complicated history) but most feeds use RSS 1.0 or RSS 0.91, both of which are lightweight yet full-featured.

RSS makes it possible for webmasters to publish and distribute information about what's new and interesting on a particular site at a particular time. This information, which could range from a list of news articles to stock market data or weather forecasts, is published as a well-formed XML document, and can therefore be parsed, processed and rendered by any XML parser - including the SimpleXML parser that is part of PHP 5.

Quite a few popular web sites make an RSS or RDF news feed available to the public at large. Freshmeat and Slashdot both have one, and so do many others, including the PEAR, PECL and Zend sites. A quick Google search for public RSS feeds will get you more links than you can shake a stick at.

An RSS document typically contains a list of resources (URLs), marked up with descriptive metadata. Here's an example:

<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/">
<channel rdf:about="http://www.melonfire.com/">
  <description>Well-written technical articles and tutorials on web technologies</description>
    <li rdf:resource="http://www.melonfire.com/community/columns/trog/article.php?id=100" />
    <li rdf:resource="http://www.melonfire.com/community/columns/trog/article.php?id=71" />
    <li rdf:resource="http://www.melonfire.com/community/columns/trog/article.php?id=62" />
<item rdf:about="http://www.melonfire.com/community/columns/trog/article.php?id=100">
  <title>Building A PHP-Based Mail Client (part 1)</title>
  <description>Ever wondered how web-based mail clients work? Find out here.</description>
<item rdf:about="http://www.melonfire.com/community/columns/trog/article.php?id=71">
  <title>Using PHP With XML (part 1)</title>
  <description>Use PHP's SAX parser to parse XML data and generate HTML pages.</description>
<item rdf:about="http://www.melonfire.com/community/columns/trog/article.php?id=62">
  <title>Access Granted</title>
  <description>Precisely control access to information with the SQLite grant tables.</description>

As you can see, an RDF file is split up into clearly demarcated sections. First comes the document prolog, namespace declarations, and root element. This is followed by a <channel> block, which contains general information on the channel that is described by this RDF file. In the example above, the channel is Melonfire's Trog column, which gets updated every week with new technical articles and tutorials.

The <channel> block contains an <items> block, which contains a sequential list of all the resources described within the RDF document. Every resource in this block corresponds to a resource described in greater detail in a subsequent <item> block. Every <item> block describes a single resource in greater detail, providing a title, an URL and a description of that resource. It's this information that our application will use to generate a personalized news feed.

How to do Everything with PHP & MySQL
How to do Everything with PHP & MySQL, the best-selling book by Melonfire, explains how to take full advantage of PHP's built-in support for MySQL and link the results of database queries to Web pages. You'll get full details on PHP programming and MySQL database development, and then you'll learn to use these two cutting-edge technologies together. Easy-to-follow sample applications include a PHP online shopping cart, a MySQL order tracking system, and a PHP/MySQL news publishing system.

Read more, or grab your copy now!

previous page more like this  print this article  next page
In trog...
Logging With PHP
Building A Quick-And-Dirty PHP/MySQL Publishing System
Output Buffering With PHP
Date/Time Processing With PHP
Creating Web Calendars With The PEAR Calendar Class
In the hitg report...
Crime Scenes
Animal Attraction
Lord Of The Strings
In boombox...
Patience - George Michael
Think Tank - Blur
My Private Nation - Train
In colophon...
Hostage - Robert Crais
The Dead Heart - Douglas Kennedy
Right As Rain - George Pelecanos
In cut!...
American Chai
The Core
Find out how you can use this article on your own Web site!

Copyright © 1998-2018 Melonfire. All rights reserved
Terms and Conditions | Feedback