Skip to content

Instantly share code, notes, and snippets.

@vladimirlukyanov
Created September 12, 2014 17:50
Show Gist options
  • Save vladimirlukyanov/54de24ad158c8f8b0ad4 to your computer and use it in GitHub Desktop.
Save vladimirlukyanov/54de24ad158c8f8b0ad4 to your computer and use it in GitHub Desktop.
Simple RSS parser
<?php
$i = 0; // counter
$url = "http://www.banki.ru/xml/news.rss"; // url to parse
$rss = simplexml_load_file($url); // XML parser
// RSS items loop
print '<h2><img style="vertical-align: middle;" src="'.$rss->channel->image->url.'" /> '.$rss->channel->title.'</h2>'; // channel title + img with src
foreach($rss->channel->item as $item) {
if ($i < 10) { // parse only 10 items
print '<a href="'.$item->link.'">'.$item->title.'</a><br />';
}
$i++;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment