Jump to content

PHP, XML and Magpie


james13009

Recommended Posts

Im using the above technologies to read feeds, i just need some help with my php coding, this is what i have that works, it reads the first 5 items in an xml feed:

 

<?php
include('../../Rss/chart2Rss/rss_fetch.inc');// Set error reporting for this
error_reporting(E_ERROR);// Fetch RSS feed
$rss = fetch_rss('http://www.nationalspares.co.uk/XML/rss3.xml');
if ($rss)
{
// Split the array to show first 5
$items = array_slice($rss->items, 0, 5);
// Cycle through each item and echo
foreach ($items as $item ) 
{
echo '<li><a href="'.$item['link'].'">'.$item['title'].'</a> - '.$item['author'].'</li>';



}}else {  echo '<h2>Error:</h2><p>'.magpie_error().'</p>';}// Restore original error reporting value@ini_restore('error_reporting');


?>

 

But what i really want it to do is to only select items within the feed with certain content,

 

for example only select the items which have the category as "Hits" , in the feed here:

 

http://www.nationalspares.co.uk/XML/rss3.xml

 

So what im looking for is a 'where' statement, any help appreciated

 

Thanks in advance James

Link to comment
https://forums.phpfreaks.com/topic/80811-php-xml-and-magpie/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.