A quick-n-dirty RSS parser that does not require that XML support be compiled into PHP. It does require PHP v4 with PCRE support. Website
By : Matt
<?php
/******************************************************************* * $Id: class.RSS.php3,v 0.91 2001/06/11 06:54:07 cdi Exp $ * * class.RSS.php3 * Version: 0.91 (natch!) * Author: Joseph Harris (CDI) * Copyright (C) 2001, Joseph Harris * cdi@thewebmasters.net * http://www.thewebmasters.net/ * ******************************************************************* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ******************************************************************* * * I use a tab stop of (4) in my editor, so this file may look weird * if you have your tab stop set differently. * * This class will completely parse RSS 0.91 compliant data. * Reference the 'rss-0.91.dtd' included with this distribution * or visit 'http://my.netscape.com/publish/formats/rss-0.91.dtd' * or 'http://www.webreference.com/authoring/languages/xml/rss/1/' * * Requires: PHP4 w/PCRE support * * Basic usage is extremely simple: * * $rss = new RSS ($data); * * // The call to 'new' results in the data being parsed. * // Data needs to be raw RSS data already obtained from a file or URL. * // Data needs to be one big string, no pre-processing of the data is needed. * * $allItems = $rss->getAllItems(); * $itemCount = count($allItems); * for($y=0;$y<$itemCount;$y++) { * print "\nItem [$y] has data\n"; * print "[$y]: Title: " . $allItems[$y]['TITLE']; * print "\n[$y]: Link : " . $allItems[$y]['LINK']; * print "\n[$y]: Desc : " . $allItems[$y]['DESCRIPTION']; * } * */
class RSS { var $CHANNELS = array(); // Array, holds individual channel data var $CHANNELINFO = array(); // Array that holds NON-ITEM channel data
DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.