Page 1 of 1

php RSS

Posted: Tue Jun 12, 2007 12:06 pm
by realtime158
I was wondering i am really struggling with this. Want i want to do is read a RSS feed and grab all the links and output them as a string. I Am using PHP 4.4.4.

Thanks...

Posted: Tue Jun 12, 2007 12:35 pm
by superdezign
There are a few XML parsers available for and built-in to PHP. You should check the documentation and look into them.

Also, if ALL you want are the links, it maybe be simpler to use regex. Otherwise.. XML Parser!

Posted: Tue Jun 12, 2007 5:47 pm
by aaronhall
SimplePie is delicious

Posted: Tue Jun 12, 2007 6:29 pm
by Ollie Saunders
For parsing XML in PHP 4 your have a choice of DOM XML, which is crap, or SAX, which is crap. You can google for tutorials on either of these (you'll probably be able to find ones specific to RSS in fact), I'd probably go with SAX because at least that isn't a bastardized implementation and the RSS data structure is pretty simple.

PHP 5 has much better implementation of DOM as well as the very popular SimpleXML.

Posted: Tue Jun 12, 2007 6:37 pm
by aaronhall
The problem with parsing RSS feeds with inbuilt abstraction libraries is having to deal with the syntactical variations across different versions of RSS, and writing extra code to deal with Atom if need be. A library like SimplePie does all the work for you.

Posted: Tue Jun 12, 2007 7:20 pm
by Ollie Saunders
You make a good point. But that library looks really bloated and personally I won't touch anything without very good unit test coverage.

Posted: Tue Jun 12, 2007 7:26 pm
by aaronhall
You're right: it is a little hefty, includes caching support and a lot of other junk you probably wouldn't use. It's fairly modular though, so you probably won't incur the extra bloat if you don't use it.

realtime158: If you have a very specific application for the RSS parser, you might just write your own as ole suggested.