• Revista PROGRAMAR: Já está disponível a edição #53 da revista programar. Faz já o download aqui!

Sign in to follow this  
Followers 0

[PHP]RSS-PHP; a free RSS Parser for PHP 5+

1 post in this topic

RSS-PHP is a free RSS Parser for PHP 5+, a single class which utilises the DOM to parse any RSS feed into a simple Object comprising of three Array's.

Unlike many RSS Parsers, RSS_PHP also gives you full access to every part of the original RSS feed; including attributes, extensions and values.

I've specifically kept rss-php as simple as possible. Here's a working example:


    $rss = new rss_php;


    $items = $rss->getItems(); #returns all rss items

Full documentation and examples of RSS-PHP are available on the site, and you can download the latest version of RSS-PHP for use in your PHP applications for free.

Site: http://rssphp.net/

Estava aqui à procura duma class que me poupasse o trabalho de parsar RSS e encontrei esta que é simples e faz o serviço sem grandes enfeites. :thumbsup:

Aqui fica um exemplo muito rabuscado usando o RSS do P@P:


header("Content-Type: text/html; charset=utf-8");	
include "lib/rss_php.php";

$x = new rss_php;
$y = $x->getRSS(true);
$items = $y['rss']['value']['channel']['value'];

echo "<table border='1'>";
echo "          <tr>
              <td align='center'>Nome do Post (Quadro)</td>
              <td align='center'>Descrição</td>
              <td align='center'>Data</td>

$items = $y['rss']['value']['channel']['value'];
foreach($items as $k => $item){
if(substr($k, 0, 4) != "item") continue;
$item = $item["value"];
printf("          <tr>
              <td align='center'><a href='%s'>%s</a> (%s)</td>
              <td align='center'>%s</td>
          </tr>", $item['guid']['value'] , $item['title']['value'], $item['category']['value'],
                              $item['description']['value'], $item['pubDate']['value']);

echo "</table>";





Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
Followers 0