PHP Classes

RSS Feed Reader: Parse and display items of an RSS feed

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 60%Total: 5,907 All time: 393 This week: 488Down
Version License PHP version Categories
rss_feed_reader 2.2GNU General Publi...5HTML, XML
Description 

Author

Simple class for parsing RSS feeds.

Returns feed as array so you can do what you wish with results.

It supports SimpleXML parsing, the old XML parser and even text parser, based on regexps.

There is also support for multiple ways to read the feed (cURL, file_get_contents and fopen). It also supports category tags.

Picture of Daniel Tlach
Name: Daniel Tlach <contact>
Classes: 2 packages by
Country: Czech Republic Czech Republic
Age: 40
All time rank: 4075 in Czech Republic Czech Republic
Week rank: 195 Up1 in Czech Republic Czech Republic Up

Recommendations

Extract last modified date of a website from RSS feed
I want to get the last modified date of a website

Example

<?php

header
( 'Content-Type: text/html; charset=utf-8' );

error_reporting(E_ALL);
ini_set('display_errors', true);

include
'./Rss.minified.php'; // include library

$Rss = new Rss; // create object

/*
    XML way
*/
try {
   
$feed = $Rss->getFeed('http://blog.danaketh.com/rss/items', Rss::XML);
    echo
'<pre>';
    foreach(
$feed as $item) {
        echo
"<b>Title:</b> <a href=\"$item[link]\">$item[title]</a>\n";
        echo
"<b>Published:</b> $item[date]\n";
        echo
"<b>Category:</b> $item[category]\n";
        echo
"\n$item[description]\n";
        echo
"<hr/>";
    }
    echo
'</pre>';
}
catch (
Exception $e) {
    echo
$e->getMessage();
}

/*
    SimpleXML way
*/
try {
   
$feed = $Rss->getFeed('http://blog.danaketh.com/rss/items', Rss::SXML);
    echo
'<pre>';
    foreach(
$feed as $item) {
        echo
"<b>Title:</b> <a href=\"$item[link]\">$item[title]</a>\n";
        echo
"<b>Published:</b> $item[date]\n";
        echo
"<b>Category:</b> $item[category]\n";
        echo
"\n$item[description]\n";
        echo
"<hr/>";
    }
    echo
'</pre>';
}
catch (
Exception $e) {
    echo
$e->getMessage();
}

/*
    Text way
*/
try {
   
$feed = $Rss->getFeed('http://blog.danaketh.com/rss/items', Rss::TXT);
    echo
'<pre>';
    foreach(
$feed as $item) {
        echo
"<b>Title:</b> <a href=\"$item[link]\">$item[title]</a>\n";
        echo
"<b>Published:</b> $item[date]\n";
        echo
"<b>Category:</b> $item[category]\n";
        echo
"\n$item[description]\n";
        echo
"<hr/>";
    }
    echo
'</pre>';
}
catch (
Exception $e) {
    echo
$e->getMessage();
}


  Files folder image Files (4)  
File Role Description
Accessible without login Plain text file example.php Example Example usage
Accessible without login Plain text file licence.txt Lic. Licence
Plain text file Rss.minified.php Class Minified version of the class
Plain text file Rss.php Class Class source file

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 0%
Total:5,907
This week:0
All time:393
This week:488Down
User Ratings User Comments (3)
 All time
Utility:86%StarStarStarStarStar
Consistency:85%StarStarStarStarStar
Documentation:-
Examples:90%StarStarStarStarStar
Tests:-
Videos:-
Overall:60%StarStarStarStar
Rank:1099
 
Very good class, but i've need a change, in place to use file...
14 years ago (jorge)
57%StarStarStar
very good!
15 years ago (raphael souza)
70%StarStarStarStar
Very good and simple one.
15 years ago (Thales Jacobi)
60%StarStarStarStar