Jump to content

does anyone have a simple RSS code that works


billy2shoe

Recommended Posts

this snippet of code will read and parse the RSS feed XML file:

 

<?php

// The @ is to supress the function´ errors

$newsfeed = 'http://url/to/file.xml';

$fp = @fopen($newsfeed, 'r');
while(!feof($fp)){
  $row .= @fgets($fp, 4096);
}
@fclose($fp);

if( eregi('<item>(.*)</item>', $row, $rowitem ) ) {
$item = explode('<item>', $rowitem[0]);

for( $i = 0; $i < count($item) - 1; $i   ) {

  eregi('<title>(.*)</title>', $item[$i 1], $title );
  eregi('<url>(.*)</url>', $item[$i 1], $url );
  eregi('<categorie>(.*)</categorie>', $item[$i 1], $categorie);

  echo '<a href="' . $url[1] . '">' . $title[1] . '</a> - ' . $categorie[1] . '<br />';

}
}

?>

Link to comment
Share on other sites

It depends on the feed. Imagine this. The 'feeder' site publishes an XML file that you pull into your site using the snippet of code. The XML file contains instructions to parse the last 25 tutorials added to their database which is added to daily by various authors, let's say. So, no matter what, each day as long as there are new tutorials published they will be fed to your site and displayed. New content. Simple.

Link to comment
Share on other sites

You could have the XML set for the last 100 if you want. Just have to make sure you have room for them on your page. The other key is, you can use that same snippet in dozens of locations throughout your site (like category pages) and just have it call a different XML file relative to the topic you've placed it in.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.