Trouble reading RSS data in AS3

I am trying to read a simple RSS feed in flash, but keep bumping into namespace issues. What's the proper way to get the content url from the following rss feed?

<rss version="2.0" xmlns:rbinl="http://reedbusiness.nl/rss/2.0" xmlns:media="http://search.yahoo.com/mrss/">
    <channel>
        <item>
          <media:content url="howtogetthis.jpg"/>
          <title>This can be read from AS3</title>
        </item>
    </channel>

AS3 Code:

// this is working
xml.channel.item[0].title;

// this is not working
xml.channel.item[0].media.@url;

Answers


You need to reference the media namespace to access that content node with the url.

Here is an example:

//get a reference to the media namespace
var ns:Namespace = new Namespace("http://search.yahoo.com/mrss/");

//use ns::content to get a reference to a `content` node in the media namespace
xml.channel.item[0].ns::content.@url;

Keep in mind, namespaces prefix nodes. So the node name is content, not media.


Need Your Help

Which is the better method? Allowing the thread to sleep for a while or deleting it and recreating it later?

multithreading sleep

We have a process that needs to run every two hours. It's a process that needs to run on it's own thread so as to not interrupt normal processing.

JSF : Elements of ArrayList are not rendered properly?

java jsf data-structures arraylist

I am trying to display elements of arrayList on xhtml page, but every time i upload new file then on status page i get multiple entries of last uploaded file rather then having details about all el...