Parsing RSS Using Magpie and Ajax
DMXZone.com has recently published an article of mine explaining how to parse RSS feeds using an open source PHP library called Magpie, and Ajax to handle the loading of the feeds. The feed reader is scalable to display as many or as few feeds as needed using an array to conveniently configure the script. If JavaScript is disabled or unavailable in the browser, the script gracefully degrades to offer a manual method of loading the feed headlines to the page rather than becoming disabled because of the Ajax calls that load them normally. Ajax is used in this example because fetching and parsing many feeds from many sources can result in an excessive page load delay as the script waits for all results to arrive. Using Ajax, you can display the headlines for each feed as they are received, resulting in an improved user experience.
You can take a look at the finished example, and download the code archive to see how it works.





Thanks for this code, Aarron. I used it and it works great.
I have a question, though. I was wondering if there was a way to make the displayed text more SEO friendly. As you know, one of the benefits of having blog headings on a page is there is the potential for these headings to contain keywords, which could enhance the page’s visibility. Also, the changing content looks good to search engines, making the site look like it is updated frequently.
Since the headings are brought in dynamically they lose that SEO benefit. I don’t know enough about PHP/Ajax/Rss to evaluate any alternatives or solutions. I was wondering if this is something you’ve thought about or had a solution for?
February 5th, 2007 at 12:18 pmThis is a good question that is addressed by building these sorts of JavaScript driven applications in an accessible manor. The solution is actually already built into the article. I use a noscript tag to show a link that manually loads in the RSS headlines if JavaScript is disabled/not available. Search engine spiders will trigger that link and get to the headlines all the same, refreshing the page with the headlines loaded. The PHP script looks to see if the RSS parsing request is coming from an Ajax call or a regular, JavaScript free call. The result is a slower load when done without the Ajax because all of the headlines have to be parsed before sending it to the browser, but the content is still the same. This is generically referred to as Progressive Enhancement.
Jeremy Keith has a book that will be coming out this month called “Bulletproof Ajax” that explores other Progressive Enhancement techniques in more detail.
February 5th, 2007 at 1:52 pmThis is a good example of clever ajax usage but still does not produce the desirable SEO effects.
December 2nd, 2007 at 8:08 amA perfect SEO solution would use the same page and render the same html results whether a client uses javascript or not.