View Full Version : Retrieval/extraction of data from rss feed through javascript

01-20-2009, 07:36 PM
Firstly, I'm quite new to this so if the answer to this is obvious I apologise. I've searched on a few places but can't quite seem to find what I'm looking for.

I've been trying to create a bookmarklet in Firefox that will allow me to register details of xml/rss feeds of podcasts on this page for Reciva internet radio devices (http://www.reciva.com). Everytime I wish to enter a podcast into the "My Podcasts" section of that website, I am required to complete a form entering the details of the feed's title and url. I quite easily managed to create a script in a firefox bookmark with the following:

which provides the site with the title of the feed in the required field "podcastname" and the url in the field "podcasturl". The code works well and the podcast is registered without a problem. However, the "My Podcasts" part of the reciva website also includes an optional "Description" field, "podcastdescription". I'd like to be able to have the script extract the value of the <description> tag from the <channel> section of the feed as this field. Obviously I'd have to add a further
&podcastdescription='+????+' and I'm wondering what exactly is needed where I wrote "????" to extract the information stored in the <description> tag.

To give an example, when the bookmark with the above script is clicked whilst looking at this feed (http://xpn.org/podcasts/daytrotter/daytrotterpodcast.xml), the title "Daytrotter on Y-Rock Podcast" is added as the "podcastname" field, the url "http://xpn.org/podcasts/daytrotter/daytrotterpodcast.xml" is added as the "podcasturl" field but I can't seem to find a way of retrieving the contents of <description>, which in this case contains "A podcast version of the weekly Daytrotter Radio feature on Y-Rock on XPN hosted by Sean Moeller". How would I go about this?

Any help would be greatly appreciated.

01-21-2009, 09:27 PM
I've been trying to solve this again and I'm wondering if there's anyway of getting this data using getElementsByTagName("description"). Like I said above I'm quite new to this so I've only a vague understanding of how it works. My attempts at this haven't worked but I thought I'd ask if I was looking in the right direction.

Also, since <description> is a tag the <channel> section of rss files, could anyone provide a link to some kind of web resource for javascript in relation to xml/rss?

rnd me
01-22-2009, 06:50 AM
the complication is that a funky browser-generated html page is displayed when viewing an rss feed.

i could not seem to get ajax to work in a bookmarklet when viewing a feed, so you can't simply pull in the file a process like a regular xml file...

perhaps you can poke around in firebug and find a tag that contains the data you want in the page firefox displays.

01-22-2009, 07:37 PM
Thanks for the reply.

Firebug solved it for me. It appears that the <description> tag of an rss feed can be accessed using

It appears that the browser-generated page reads <description> as <h2 id="feedSubtitleText"> and by looking through firebug I found that textContent gave me the contents.

Thus the code I needed was:

which can be added as the url of a bookmark no problem. Works great.

Thanks again :thumbsup:

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum