billy2shoe Posted February 3, 2007 Share Posted February 3, 2007 does anyone have any simple RSS code that works .. i would like to learn about this... (please dont post a site..as all the sites i find with code seem not to work????) http://www.phpit.net/article/screenscrap-rss/2/ what would be awesome is someone that has an example that WORKS.. ie returns something when u run it Quote Link to comment Share on other sites More sharing options...
simcoweb Posted February 3, 2007 Share Posted February 3, 2007 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 />'; } } ?> Quote Link to comment Share on other sites More sharing options...
ted_chou12 Posted February 3, 2007 Share Posted February 3, 2007 Can I ask a question here? although i have searched it on google, but i dont understand how they had defined RSS, can anyone explain to me what is the purpose of it? Thanks Ted Quote Link to comment Share on other sites More sharing options...
simcoweb Posted February 3, 2007 Share Posted February 3, 2007 Simple. To provide an easy way to import continually updated content into your site (or, export to sites). To 'syndicate'. Quote Link to comment Share on other sites More sharing options...
ted_chou12 Posted February 3, 2007 Share Posted February 3, 2007 how does it continually updated content on to my site? Thanks Ted Quote Link to comment Share on other sites More sharing options...
simcoweb Posted February 3, 2007 Share Posted February 3, 2007 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. Quote Link to comment Share on other sites More sharing options...
ted_chou12 Posted February 3, 2007 Share Posted February 3, 2007 oh, i see, if i display ten most recent tutorials, and i have ten already, what happens when i add one more to the xml? does the 11th one get washed away? Ted Quote Link to comment Share on other sites More sharing options...
simcoweb Posted February 3, 2007 Share Posted February 3, 2007 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. Quote Link to comment Share on other sites More sharing options...
ted_chou12 Posted February 3, 2007 Share Posted February 3, 2007 thanks, i think i sort of understand it better. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.