[nycphp-talk] PeterSaw, how about a tutorial on RSS feed?
gadhra
bfeqx44002 at sneakemail.com
Fri May 2 09:58:10 EDT 2003
Hi Pinyo,
I can recommend very highly the PEAR RSS parser at
http://pear.php.net/package-info.php?pacid=22. It's a snap to use and
I've had great results.
I use it on my website, http://www.gadhra.com, to get RSS feeds from
some sites I like. Here's how I use it:
<?php
/* Here's a little function to iterate through the channel array */
function parse_feed($arr,$num) {
$str = "<ul>";
for ($i=0;$i<$num;$i++) {
$str .= "<li><a href=\\"".$arr[$i]['link']."\\"
target=\\"".$arr[$i]['title']."\\">".$arr[$i]['title']."</a></li>";
}
$str .= "</ul>";
return $str;
}
/* create a new object from the XML_RSS class and parse that sucker */
$rss =& new XML_RSS("http://enter_rss_feed_here");
$rss->parse();
$channels = $rss->getChannelInfo();
/* Now, display the feed using the parse_feed function */
?>
<html>
<body>
<a href="<?=$channels['link']; ?>" target="<?=$channels['title'];
?>"><?=$channels['title']; ?></a>
<?= parse_feed($rss->getItems(),3); ?>
</body>
</html>
That's all there is to it!
+gadhra+ (Stefan)
Pinyo Bhulipongsanon pinyo-at-nyc.rr.com |NY PHP| wrote:
>Hi Peter,
>
>How do I turn something like this
>http://www.marktaw.com/rss.xml
>
>To show up in my web site?
>
>Thanks,
>
>Pinyo
>
>
>--- Unsubscribe at http://nyphp.org/list/ ---
>
>
>
>
>
>
>
--
+gadhra+(/s)
*********************
XXXXXXXXXXXXXXXXX
And seize the metropolis;
It's you it's built on
More information about the talk
mailing list