Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jan 2009
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question Retrieval/extraction of data from rss feed through javascript

    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. 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:
    Code:
    javascript:void(location.href='https://www.reciva.com/index.php?option=com_mypodcasts&podcastname='+document.title+'&podcasturl='+location.href+'&podcast_task=add')
    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
    Code:
    &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, the title "Daytrotter on Y-Rock Podcast" is added as the "podcastname" field, the url "http://xpn.org/podcasts/daytrotter/d...terpodcast.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.

  • #2
    New to the CF scene
    Join Date
    Jan 2009
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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?

  • #3
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,460
    Thanks
    11
    Thanked 600 Times in 580 Posts
    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.
    my site (updated 2014/10/20)
    BROWSER STATS [% share] (2014/9/03) IE7:0.1, IE8:4.3, IE11:9.2, IE9:2.7, IE10:2.6, FF:16.8, CH:47.5, SF:7.8, NON-MOUSE:37%

  • Users who have thanked rnd me for this post:

    annoyingmouse (01-22-2009)

  • #4
    New to the CF scene
    Join Date
    Jan 2009
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks for the reply.

    Firebug solved it for me. It appears that the <description> tag of an rss feed can be accessed using
    Code:
    javascript:document.getElementById("feedSubtitleText").textContent
    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:
    Code:
    javascript:void(location.href='https://www.reciva.com/index.php?option=com_mypodcasts&podcastname='+document.title+'&podcasturl='+location.href+'&podcastdescription='+document.getElementById("feedSubtitleText").textContent+'&podcast_task=add')
    which can be added as the url of a bookmark no problem. Works great.

    Thanks again


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •