Home | Scripts | Tutorials | Books | Hosting | Forums | Links|

Navigation:

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






 
 

SPONSORS



 
 

Putting news from ABC on your site

This shows how to put various ABC headlines on your site .

Category XML link
ABC news http://abc.net.au/news/hlines.rss
Entertainment http://www.newsisfree.com/HPE/xml/feeds/37/1837.xml
Health http://www.newsisfree.com/HPE/xml/feeds/41/1841.xml
International http://www.newsisfree.com/HPE/xml/feeds/39/1839.xml
Science http://www.newsisfree.com/HPE/xml/feeds/40/1840.xml
US http://www.newsisfree.com/HPE/xml/feeds/38/1838.xml
   

This example will show the international news

Code :

<?php
$xmlfile = fopen("http://www.newsisfree.com/HPE/xml/feeds/39/1839.xml", "r");
if(!$xmlfile)die("cannot open the xml file");
$readfile = fread($xmlfile ,40000);
$searchfile = eregi("<item>(.*)</item>", $readfile ,$arrayreg);
$filechunks = explode("<item>", $arrayreg[0]);
$count = count($filechunks);
echo "<table border='1'>";
echo "<th colspan='3'>latest news</th>";
for($i=1 ; $i<=$count-1 ;$i++)
{
ereg("<title>(.*)</title>",$filechunks[$i], $title);
ereg("<link>(.*)</link>",$filechunks[$i], $links);
ereg("<description>(.*)</description",$filechunks[$i],$desc);
echo "<tr><td>";
echo $title[1];
echo "</td><td>";
echo "<a href ='$links[1]'\>$links[1]</a>";
echo "</td><td>";
echo $desc[1];
echo "</td></tr>";
}
echo "</table>";
?>

Example :

 


Warning: fopen() [function.fopen]: URL file-access is disabled in the server configuration in /home/beginne/public_html/abcfeeds.php on line 247

Warning: fopen(http://www.newsisfree.com/HPE/xml/feeds/39/1839.xml) [function.fopen]: failed to open stream: no suitable wrapper could be found in /home/beginne/public_html/abcfeeds.php on line 247
cannot open the xml file