Forum Moderators: coopster
<?php
include('magpierss/rss_fetch.inc');
// Set error reporting for this
//error_reporting(E_ERROR);
// Fetch RSS feed
define('magpierss', 'magpierss/');
require_once(magpierss.'rss_fetch.inc');
$rss = fetch_rss( 'http://www.example.com/services/xml/rss/nyt/Books.xml');
if ($rss)
{
// Split the array to show first 10
$items = array_slice($rss->items, 0, 10);
// Cycle through each item and echo
foreach ($items as $item )
{
echo '<ol><a href="'.$item['link'].'">'.$item['title'].'</a> '.$item['author'].'<br />'.$item['description'].'</ol>';
}}else { echo '<h2>Error:</h2><p>'.magpie_error().'</p>';}
// Restore original error reporting value@ini_restore('error_reporting');
?>
</div>
[edited by: dreamcatcher at 6:05 pm (utc) on Aug. 23, 2007]
[edit reason] Use example.com, thanks. [/edit]
I say this because you might want your html markup to look like this:
<ol>
<li>Item in the list 1</li>
<li>Item in the list 2</li>
</ol>
instead of:
<ol> Entirely new list 1</ol>
<ol> Entirely new list 2 </ol>
echo '<ol>';
foreach ($items as $item )
{
echo '<li><a href="'.$item['link'].'">'.$item['title'].'</a> '.$item['author'].'<br />'.$item['description'].'</li>';
}
echo '</ol>';
but it didn't work.
I'm not quite sure what to try next. I'll let you know if I figure it out.
Thanks again.