Common RSS Reader
This library holds only a single function that is able to display any feed
in any format.
The URL of the file may be local, in the form: rss.xml, or remote in
the form: http://www.xul.fr/rss.xml.
The function displays the channel and the articles and for each of them the
title, the description and the dates.
The date is not displayed for the RSS RDF 1.0 format because it is not a part of the core specification.
The script is compatible with:
- Atom 1.0
- RSS 2.0
- RSS 0.91, 0.92, 0.94
- RSS RDF 1.0
The interface
The interface is comprised of a single function:
Common_Display(url, size, channel-option, desc-option, date-option)
The interface requires one argument, the url, and supports four optional arguments:
- url:
the address of the XML file. - size:
the maximum number of items to display. The default is 25. - channel-option:
true if the chanel is displayed, false elsewhere. Default true. - desc-option:
true if the descriptions are displayed or else false. Default true. - date-option:
true if the dates are displayed or else false. Default false.
Source code
The source is a combination of the Atom and RSS readers. Main internal functions are these:
Atom_Retrieve() // parse the feed element and its entries. RSS_Retrieve() // parse the channel element and its items.View the commonlib.php script.
Demos
Demos are templates you can study and use on you own site, according to the Mozilla licence. A form allows to enter the URL of the feed. You can remove the form and replace it by a direct URL of a feed. The feed may be displayed into the same page or into another one.
- Displaying directly an RSS feed on a page, without to enter the URL.
- Displaying directly an Atom feed on a page.
- Displaying any feed with
any options.
Download
The archive holds the script and the demos.
- Common Reader. The script requires PHP 5. Demos and manual included.
Documentation
- The Common RSS interface. Short manual.
- How to build
an RSS feed. Tutorial.