Your Ad Here

 Navigation
Home
Source code
Tutorials
RSS feeds
Articles
Wordpress plugins
Books
Sample Chapters
Software
Downloads
Hosting
manuals
Script directory
Training
Our Links




 Sponsors
 Links
domain names
programmershelp
finance products
 Downloads
dzphp editor
EasyPHP
mysql_phpgenerator
php-studio-trial
phpdesigner_7_2_5
phpMyAdmin-3.4.3.2
/phptriad2-2-1
phpxedit_321
rapidphp 2011
WampServer2.1d-x64
WampServer2.1e-x32
xampp-win32-1.7.4-VC6-installer
xampplite-win32-1.7.3
 Misc
Webmaster Resources
Only PHP
ScriptSearch.com
Scripts.com - Get the best scripts NOW!
AndreaPHP Programming

Valid XHTML 1.0 Transitional


Valid CSS!

RSS feeds with Pear packages

The objective here is to display an RSS feed. We have picked one that looks interesting from the BBC website, we will have alook at the science and nature news feed which is http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/sci/tech/rss.xml

Firstly we are going to use 2 Pear packages to achieve this we will need the XML_Parser package and also the XML_RSS package. Underneath you can see 2 dowload links to get these packages.

XML_parser package
XML_RSS package

Now download these to a location on your PC and extract all of the contents in them.

The next step involves creating a folder on your website, this is where we tend to upload all of these packages. In this case lets call it the pear folder.

Create a folder called xmlparser and xmlrss and put the contents of the respective dowloaded packages into the folders.

The first step requires opening the RSS.php file that you should now see in the xmlrss folder, locate the line of code that begins with

require_once 'XML/Parser.php';

change this to the following to allow the script to work

require_once 'pear/xmlparser/Parser.php';

Now for the script to get this all working

<?php
require_once "pear/xmlrss/RSS.php";
//this is the rss news feed you wish to display
$rss =& new XML_RSS("http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/sci/tech/rss.xml");
$rss->parse();
//display a line of text saying where this is from (good manners)
echo "<h1>Headlines from <a href=\"http://www.bbc.co.uk\">BBC Science/Nature</a></h1>\n";
echo "<ul>\n";
//loop through all of the items
foreach ($rss->getItems() as $item)
{
echo "<li><a href=\"" . $item['link'] . "\">" . $item['title'] . "</a></li>\n";
}

echo "</ul>\n";
?>

If you look at the bottom of the page you can see this in action



Headlines from BBC Science/Nature



Books
 Sponsors


 Random Code
Show MySQL tables(database)
populate a select menu from MySQL(database)
Display the date a page last modified(date and time)
 Random Article
  Network
Programming resources
Tutorials directory
Hosting resources
ASP site
Domain names
Progged
Maxi directory
bigarticle : free articles
A Code
Code N Tutorials
Get PHP
Programmers help




beginners PHP Copyright © 2004 onwards by beginnersPHP.