Your Ad Here

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




 Sponsors
 Links
low cost magazines
gambling sites
dvd information
 Downloads
 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
using the array_splice function(beginner)
If Else statement(beginner)
Reading RSS feeds with PEAR xml_rss package(pear)
 Random Article
  Network
Programming resources
Tutorials directory
Clickbank mall
sell software
Free auctions, low cost stores
UK products
US products
Gambling directory
Sexy free wallpapers
Hosting resources
ASP site
DVD site
Domain names
Dating site
Software directory
Maxi directory
bigarticle : free articles




beginners PHP Copyright © 2004 onwards by beginnersPHP.