[PHP] Parsing RSS

2006-08-12 Thread John Taylor-Johnston
Is there something already created to open an rss file, parse it, and 
include() the useful stuff into an html file?

Not all my students have an rss reader.

http://jtjohnston.ca/jtjohnston.rss

jt

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Parsing RSS

2006-08-12 Thread Dave Goodchild

On 12/08/06, John Taylor-Johnston 
[EMAIL PROTECTED] wrote:


Is there something already created to open an rss file, parse it, and
include() the useful stuff into an html file?
Not all my students have an rss reader.

http://jtjohnston.ca/jtjohnston.rss





Yep. The PEAR XML_RSS class.



for example:

$feed = 'foo.rss';

$rss = new XML_RSS($feed);
$rss-parse();

foreach ($rss-getItems() as $item) {
// output rss
}




--
http://www.web-buddha.co.uk
http://www.projectkarma.co.uk


Re: [PHP] Parsing RSS

2006-08-12 Thread Rasmus Lerdorf

John Taylor-Johnston wrote:
Is there something already created to open an rss file, parse it, and 
include() the useful stuff into an html file?

Not all my students have an rss reader.

http://jtjohnston.ca/jtjohnston.rss


RSS is just XML.  Use SimpleXML to map it to a PHP object and just print 
out whatever you want from it directly.


eg.

?php
$rss = simplexml_load_file('http://jtjohnston.ca/jtjohnston.rss');
$channel = $rss-channel;
echo EOB
img src={$channel-image-url} style=float: right;/
h1{$channel-title}/h1
h2{$channel-description}/h2
EOB;
foreach($channel-item as $item) {
  echo EOB
h3a href={$item-link}{$item-title}/a ({$item-pubDate})/h3
{$item-description}
br clear=left /
hr /
EOB;
}
?

Very ugly HTML markup there, of course, but add a bit of CSS and make it 
prettier.


-Rasmus

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Parsing RSS

2006-08-12 Thread John Taylor-Johnston
I've gotten some excellent responses. Thanks! Anything I can implement 
in PHP 4 - until i get IT to update to PHP 5?

John

Dave Goodchild wrote:

Yep. The PEAR XML_RSS class. 





[PHP] Rasmus: [PHP] Parsing RSS

2006-08-12 Thread John Taylor-Johnston

Thanks. P.S. excellent interview with Leo Laporte!
http://www.twit.tv/floss12
Your interview made me think of Cathedrals  Bazaars and the notion of 
free riders.
I've been much of a php free rider myself, but try to find ways to give 
back, usually through phpmyadmin.net

Thanks to everyone who give their time, and responses to my queries!
John

Rasmus Lerdorf wrote:


John Taylor-Johnston wrote:

Is there something already created to open an rss file, parse it, and 
include() the useful stuff into an html file?

Not all my students have an rss reader.

http://jtjohnston.ca/jtjohnston.rss



RSS is just XML.  Use SimpleXML to map it to a PHP object and just 
print out whatever you want from it directly.


eg.

?php
$rss = simplexml_load_file('http://jtjohnston.ca/jtjohnston.rss');
$channel = $rss-channel;
echo EOB
img src={$channel-image-url} style=float: right;/
h1{$channel-title}/h1
h2{$channel-description}/h2
EOB;
foreach($channel-item as $item) {
  echo EOB
h3a href={$item-link}{$item-title}/a ({$item-pubDate})/h3
{$item-description}
br clear=left /
hr /
EOB;
}
?

Very ugly HTML markup there, of course, but add a bit of CSS and make 
it prettier.


-Rasmus


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Parsing RSS

2006-08-12 Thread John Taylor-Johnston

Richard,
Found this: http://www.phpclasses.org/browse/package/2263.html
Real small and works in PHP4. Time for a little CSS tweaking ;) and it 
will look great!

Thanks,
John
http://jtjohnston.ca/news/news.php

Richard Lynch wrote:


I'm willing to bet that if you check Google or even just
http://phpclasses.org you can find something specifically for RSS.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Parsing RSS

2001-12-03 Thread Tom Malone

Hi to all

Does anyone know of any good books or online tutorials on parsing RSS feeds
with PHP (or parsing XML in general in PHP)?

Tom Malone
Web Designer
http://www.tom-malone.com



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]