wiggst3r Posted October 1, 2008 Share Posted October 1, 2008 Hi I have a script, which I want to use the contents of as an RSS feed onto my Google homepage. The content will change on a daily basis. What's the easiest way of doing this? Thanks Link to comment https://forums.phpfreaks.com/topic/126608-rss-feeds/ Share on other sites More sharing options...
dropfaith Posted October 1, 2008 Share Posted October 1, 2008 whats the script look like you didnt give me enough details here Link to comment https://forums.phpfreaks.com/topic/126608-rss-feeds/#findComment-654735 Share on other sites More sharing options...
Chicken Little Posted October 1, 2008 Share Posted October 1, 2008 I've used Peter Lavin's (Object Oriented PHP book) code and this works for me: <?php //point to an xml file you want to feed $feed = "http://rss.news.yahoo.com/rss/mideast"; //create the object you want $sxml = simplexml_load_file($feed); foreach ($sxml->attributes() as $key => $value){ echo "<p>RSS $key $value</p>\n"; } echo "<h2>". $sxml->channel->title. "</h2>\n"; echo "<p>\n"; //iterate through the items foreach ($sxml->channel->item as $item){ $strtemp = "<a href=\"$item->link\">". "$item->title</a> $item->description<br /><br />\n"; echo $strtemp; } echo "</p>\n"; ?> Link to comment https://forums.phpfreaks.com/topic/126608-rss-feeds/#findComment-655002 Share on other sites More sharing options...
dropfaith Posted October 1, 2008 Share Posted October 1, 2008 wrap your code in the code tags makes it easier to follow <?php //point to an xml file you want to feed $feed = "http://rss.news.yahoo.com/rss/mideast"; //create the object you want $sxml = simplexml_load_file($feed); foreach ($sxml->attributes() as $key => $value){ echo "<p>RSS $key $value</p>\n"; } echo "<h2>". $sxml->channel->title. "</h2>\n"; echo "<p>\n"; //iterate through the items foreach ($sxml->channel->item as $item){ $strtemp = "<a href=\"$item->link\">". "$item->title[/url] $item->description \n"; echo $strtemp; } echo "</p>\n"; ?> Link to comment https://forums.phpfreaks.com/topic/126608-rss-feeds/#findComment-655004 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.