Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Use an open source PHP class to fetch articles from RSS, ATOM and OPML feeds
<?php
/**
* Retrieve and parse OPML (Outline Processor Markup Language) Parser Class.
* Extracts the properties of content from OPML files using a PHP class
*
* @link https://github.com/imelgrat/opml-parser
*
* @link https://imelgrat.me/php/find-atom-opml-rss-feeds/
*/
require_once('opml-parser.php');
use imelgrat\OPML_Parser\OPML_Parser;
$parser = new OPML_Parser();
// Get OPML from URL
$parser->ParseLocation('http://www.bbc.co.uk/podcasts.opml', null);
// Walk through each item in the same way as we would if $parser were a string (thanks to the Iterator interface)
foreach ($parser as $key => $item)
{
echo "<p> Item: " . $key . '</p><ul>';
foreach ($item as $attribute => $value)
{
echo '<li>' . '<strong>' . $attribute . '</strong>:' . $value . '</li>';
}
echo '</ul>';
echo '<p>&nbsp;</p>';
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment