PHP RDF Parser is yet another PHP class that parses and outputs netscape's rdf/rss (whichever you would like to call them) files. PHP RDF Parser can easily be integrated into existing web content with an easy output function, or you can use the variables within the class to arrange the data however you want.

Licensed under the GNU/GPL


The current version is: 0.1.4
You may download a tarball right here.

Retriving RDFs To Parse Them

The current version of PHP RDF Parser does not retrive rdf feeds from the internet. Right now, you may need to run something like my little perl program I call You may download it from here. Right now, I have setup as a cron job that fires every 15 minutes. The perl program looks at a database and downloads all of the feeds it finds references to in a certain table. All of those variables can be set in the first part of
Please note that I am not currently supporting and the comments within the code are terrible, so you are mostly on your own when it comes to setting it up. If you feel like it, you can email me and take the chance that I will answer your questions.


The basic steps for using PHP RDF Parser are, declare the use of the class, declare a new class, parse the file, and output the results. Here's some sample code to get you started:

require ("/home/httpd/html/rdf_class.php"); //notice the full file system path
$channel = new rdfFile("/home/httpd/html/news.rdf"); //again, full system path
$channel->ReturnTable(True, "#00FF00", "#FFFFFF", 200);

The sample code above outputs a table that is 200 pixels wide with the title cell (at the top) with a background color of green and a main body text background color of white. To see an example of what this code will output, go here. The comments for each item will be listed along with the links/titles for each item.
Also, the True parameter value for the parse function tells the parser to check for encoding mistakes. This is handy in case the author of the rdf file forgot to strickly use Latin-1 encoding. In essence, making this value True will get rid of all rogue ampersands in the rdf/rss file.

The parsing functions listed below should be used in the order they are listed. If you try to reverse the order, things will not work. (obviously)

$item = new rdfFile(string filename)
The filename passed to the class should be the full system path. See the example above.
$item->parse(boolean CheckEncoding)
CheckEncoding should be either True of False.
If CheckEncoding is True, the rdf/rss file will be searched for ampersands (&) without pound signs (#) following them. If the &# sequence is found, it is assumed that the encoding is correct and leaves the characters alone. If an ampersand is found without a following pound sign, the ampersand is removed.
If CheckEncoding is False, no check is done and you should assure that there are no rogue ampersands in the rdf/rss file because the php xml parser does not like them.
$item->ReturnTable(boolean comments, string titlebgcolor, bodybgcolor[, int tablewidth])
The argument comments should be True or False. If comments is True, the comments (if any) for each item in the rss/rdf will be displayed after the title/link of the item. If comments is False, the comments will not be displayed and the function will only output the title/link for each item.
Both the titlebgcolor and the bodybgcolor strings should be html hexidecimal color values (ex: #00FF00).
The integer tablewidth is an optional argument and should be the width (in pixles not percentage) that you wish the table to be.

The variables from within the class that you may find helpful are listed and described below. These variables cannot be called until you call the parse function. In the descriptions below, it is assumed that $item is an object of the rdfFile class.

ChannelTitleLink is the url of the home page for the channel (<a></a>).
ChannelImageUrl is the url of the image to be displayed (<img>).
ChannelImageLink is the url that the image should link to (<a></a>).
ChannelSkipHours is an array that contains the hours in the Channel-skipHours-hour tags.
ChannelSkipDays is an array that contains the days in the Channel-skipDays-day tags.
Items is a two-dimensional array containing the collective contents of title, link, and description for each item.
$item->Items[0]["Link"] holds the url/link for the first item.
$item->Items[0]["Title"] holds the title of the first item.
$item->Items[0]["Description"] holds the description for the first item.
TextInputTitle is the title of the form field text box.
TextInputName is the name of the form field to be submited (<input type="text" name="HERE">).
TextInputLink contains the url that the form should be submited to (<form action="HERE">).

Copyright(c) Jason Williams (