Log in

View Full Version : How to Limit RSS feeds?



ntin0s
03-09-2012, 12:32 AM
Hi,

I had problems parsing my rss feeds, it would parse all the feeds and I only need 5-10. I tried using a loop but it outputs the same feed 5 times.
I tried inserting rss in an array but it didnt work for me.
here is my code:

$feed_url = "http://feeds.bbci.co.uk/sport/0/football/rss.xml?edition=uk";
// Get data from feed file
$response = file_get_contents($feed_url);

// Insert XML into structure
$xml = simplexml_load_string($response);

// Browse structure
?><div class="rss-items"><?
?><div class="rss-header"><?echo "RSS FEEDS";?></div><?

foreach($xml->channel->item as $one_item)




$counter = 0;
while ($counter < 5){
++$counter;
echo ($one_item->title);

}


Any help appreciated

fastsol1
03-09-2012, 12:55 PM
Can you post up the xml array that you are working with from the feed. Have you tried just


$feed = string($xml->channel->item[0]);
echo $feed
Or any variations of things like that?

ntin0s
03-09-2012, 07:13 PM
I think a variation of this will help me. Thanks