Categories
PHP

FeedParser: A PHP Class for Quick Feed Parsing

Well, it doesn’t require any further explanation — we the web developers know how often we need to parse feeds. It’s a very common practice to use SimpleXML for parsing feeds. But today Hasin vai (Hasin Hayder) showed me a very cool thing — the Google Feed Parser. It’s a web based feed parser that is internally used by Google. The coolest thing about the parser is that it returns data as JSON 🙂

Seeing the point, I quickly fired off my netbeans IDE and wrote a php class for quick feed parsing 😀 Why fetch the feed and then parse it? Let Google handle the parsing and fetch the parsed results 🙂 Google is really making our lives simpler!

Here’s the class definition:

So, how do you use it? Initiate a new FeedParser object and then call the parse() method with the feed URL and entry count. The second parameter is optional and is “5” by default.

So what do we get in the $data array? Good question, lets see :

One reply on “FeedParser: A PHP Class for Quick Feed Parsing”

Comments are closed.