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

Firing key event ctrl + space on JTextArea?

java swing jtextarea keyevent

I'm new to Java Swing. I need to fire event ctrl + space on JTextArea

Is there a :disable_with equivalent for link_to_remote?

ruby-on-rails ajax link-to-remote

I have a link_to_remote and I want to make sure people can only click it once while waiting for it to return.