views:

98

answers:

3

I'm at a stage in which I did not learn internet scripting languages yet, but I do understand JavaScript enough to edit scripts I find on the web to suit my needs. Lately, I've been searching for an RSS to HTML converter, and was surprised to find out that it usually involves PHP. I don't see a reason for JavaScript to not be adequate for the task, so my question is- is it really not? And if so, why?

Also if you can show me some code examples I'll greatly appreciate it (I do plan to learn Javascript eventually, I'm not just leeching. I just lack the time at the moment).

+1  A: 

http://www.google.com/search?q=rss+parse+javascript

First result appears to be relevant, with source code: http://www.captain.at/howto-ajax-parse-rss.php

ceejayoz
+3  A: 

JQuery has an XML parser built in. Here's a great tutorial that details the use of the built-in feature. :)

Salty
+3  A: 

I think the reason most examples use server side scripting is that, since the Javascript same domain policy means you have to request the RSS from your own server anyway, then you may as well transform it into 'display format' on the server side too. Also, if you're doing some sort of Ajaxy stuff then there are better ways of getting the data to the script in the browser than just handing off a full RSS feed.

Having said all that, there are ways to parse RSS and similar XML feeds on the client side. One option is to just style the RSS directly using CSS and/or XSLT. I don't think using CSS for this is too common in the real world because you have to use different methods in different browsers, but transforming XML with XSLT in Firefox is fairly straightforward and I'm fairly sure it's possible in IE and the other browsers too, but XSLT may be a bit beyond your comfort zone.

A good source for Javascript examples is the Google Data APIs as they use the Atom Publishing Protocol which is conceptually similar to RSS. For example, here is the Javascript documentation for the Analytics API.

robertc