Kokodoko
Kokodoko

Reputation: 28128

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;

Upvotes: 2

Views: 46

Answers (1)

BadFeelingAboutThis
BadFeelingAboutThis

Reputation: 14406

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.

Upvotes: 1

Related Questions