RDF/XML Backend News Parser

  About these scripts Top

I wrote a few functions to parse backend news files. They are 3 functions based on the type of backend:
  • RDF files are used by My Netscape channels. The news is described using XML syntax.
    function parserdf($hostname, $uri, $port = 80, $maxitems = 0);
    • $hostname, the address of the host.
    • $uri, the path to the RDF/XML file (must start with /).
    • $port, the port on the WWW host (optional, default is 80).
    • $maxitems, the maximum number of items to display (optional, default is 0 for all items).
  • Multi line based news files where news items are described over several lines with at least one for the title and one for the link. Optionaly, the news item may be delimited by a separator line (like %%). In that case all lines up to the first separator are ignored.
    function blocknewsparser($hosttitle, $hostname, $backend, $argdesc, $separ = "", $maxitems = 0, $port = 80);
    • $hosttile, the name of the host.
    • $hostname, the address of the host.
    • $backend, the path to the text news file (must start with /).
    • $argdesc, an array of strings describing the meaning of each line. At least one of these items must be called "info" (the title of the news item) and another "link" (the URL).
    • $separ, separating line (default is empty, ie no separator).
    • $maxitems, the maximum number of items to display (optional, default is 0 for all items).
    • $port, the port on the WWW host (optional, default is 80).
  • Single lines based news files where news items are described on a single line and fields are separated by a delimiter.

  Files Top

  • RDF Parser.
  • I also wrote another version of that parser which uses the XML parser buildin to PHP. But RDF files produced by many sites are not really XML compliant and there is no easy way to handle those errors using the buildin parser.
  • Text News Parser contains the two functions for parsing plain text based news sites.
  • news formating functions are used to actually display the news parsed by the functions above. Simply modify these to change the look of news boxes on your site.
  • Two images, the document icon and the news title background (that one comes from linux.com.
  • A Style Sheet.
  • I also have two scripts which encapsulate the calls to the above scripts using form handling. For example you can use this url to include /. news on your site:
    http://mkrus.free.fr/php3/rdfnews.php3?hn=slashdot.org&url=%2Fslashdot.rdf
    If you have PHP and don't want to download my scrips you can simply include the result using fopen (since include does not support urls). If you don't have PHP, you can include this in a layer or something.
    Don't forget to encode the url which point to news files since they might also be urls (see themes.org examples below).


   Themes.Org Browser