PHP Classes

PHP RSS Feed Parser Class: Parse RSS 2.0 feeds and extract all the items

Recommend this page to a friend!
  Info   View files Example   View files View files (9)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 68%Total: 304 This week: 1All time: 7,380 This week: 560Up
Version License PHP version Categories
bartonlp-rssfeed 1.0.3MIT/X Consortium ...5XML, PHP 5
Description 

Author

This class can parse RSS 2.0 feeds and extract all the items.

It can parse a XML RSS 2.0 file or string and parse it to extract its contents.

The class returns arrays with the list of properties of each feed item.

Picture of Barton Phillips
Name: Barton Phillips is available for providing paid consulting. Contact Barton Phillips .
Classes: 5 packages by
Country: United States United States
Age: 79
All time rank: 53569 in United States United States
Week rank: 411 Up48 in United States United States Up
Innovation award
Innovation award
Nominee: 1x

Example

<?php
require '../../../../vendor/autoload.php';
use
bartonlp\RssFeed;

$rss = new RssFeed("testrss.xml", true, true);
$raw = escape($rss->getRawData());
echo
"<pre>Raw:\n$raw";

$db = $rss->getDb();
echo
"DB:\n";
var_dump($db);

$item = $rss->getItem(0);
echo
"First Item:\n";
var_dump($item);

echo <<<EOF
</pre>
<p>Item title:
{$item['title']}<br>
Item description:
{$item['description']}</p>
EOF;

// Now iterate over the items

echo "<h1>Example of Iterating Over Entire Array of Items</h1>";

foreach(
$rss->getDb() as $val) {
  foreach(
$val as $key=>$v) {
    echo
"$key: $v<br>";
  }
  echo
"<hr>";
}

echo
"DONE";

function
escape($v) {
  return
preg_replace(['~<~', '~>~'], ['&lt;', '&gt;'], $v);
}


Details

RssFeed Class

This is a PHP class that can read RSS feeds.

Install

You can either clone the repository or you can use composer to install UpdateSite.

If you do not have composer you can get it at https://getcomposer.org/download/. Just follow the instruction to install it globally.

Once you have composer select a directory where you want your repository and enter:

composer require bartonlp/rssfeed:dev-master

Documentation

Documentation for RssFeed

Example

There is an example file (test.php) in the 'docs' directory along with a XML and image file that you can run.

Contact me:

bartonphillips@gmail.com


  Files folder image Files  
File Role Description
Files folder imagedocs (6 files)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation
Plain text file RssFeed.php Class Class source

  Files folder image Files  /  docs  
File Role Description
  Accessible without login Image file image.png Data Auxiliary data
  Accessible without login HTML file index.html Doc. Documentation
  Accessible without login Plain text file index.md Doc. Documentation
  Accessible without login Plain text file mk-html.sh Data Auxiliary data
  Accessible without login Plain text file test.php Example Example script
  Accessible without login Plain text file testrss.xml Data Auxiliary data

 Version Control Unique User Downloads Download Rankings  
 100%
Total:304
This week:1
All time:7,380
This week:560Up
 User Ratings  
 
 All time
Utility:87%StarStarStarStarStar
Consistency:87%StarStarStarStarStar
Documentation:79%StarStarStarStar
Examples:83%StarStarStarStarStar
Tests:-
Videos:-
Overall:68%StarStarStarStar
Rank:385