Processing
 

Reading an Attribute from a XML/RSS file using AS3

14/02/2011 18:09#1

DomingoSL

Member

Joined at: 10 months ago

Post: 51

Thank: 0

Thanked: 0

very simple question, i have this: (only a part of the complete rss file)

 <item>       <title>Ok, de regalo de San Valentin me pueden dar un viaje a Playa del Carmen! Digo, entre todos lo pagan! No?? #So&#241;arNoCuestaNada</title>       <link>http://twitter.com/glenyvalente/statuses/37202068301295616</link>       <description>Ok, de regalo de San Valentin me pueden dar un viaje a &lt;b&gt;Playa&lt;/b&gt; del Carmen! Digo, entre todos lo pagan! No?? &lt;a href=&quot;http://search.twitter.com/search?q=%23So%C3%B1arNoCuestaNada&quot; onclick=&quot;pageTracker._setCustomVar(2, 'result_type', 'recent', 3);pageTracker._trackPageview('/intra/hashtag/#So&#241;arNoCuestaNada');&quot;&gt;#So&#241;arNoCuestaNada&lt;/a&gt;</description>       <pubDate>Mon, 14 Feb 2011 17:30:38 +0000</pubDate>       <guid>http://twitter.com/glenyvalente/statuses/37202068301295616</guid>       <author>glenyvalente@twitter.com (Gleny Valente)</author>       <media:content type="image/jpg" width="48" url="http://a1.twimg.com/profile_images/1225905511/S5030401_normal.JPG" height="48"/>       <google:image_link>http://a1.twimg.com/profile_images/1225905511/S5030401_normal.JPG</google:image_link>       <google:location>Venezuela</google:location>       <twitter:metadata>         <twitter:result_type>recent</twitter:result_type>       </twitter:metadata>     </item> 

And i read <title> and <pubDate> using:

function rssLoaded(evt:Event):void {     rssXML = XML(rssLoader.data);     for(var item:String in rssXML.channel.item) {     fechas.push(rssXML.channel.item[item].pubDate.substr(0, 16));     titulos.push(rssXML.channel.item[item].title);     trace(rssXML.channel.item[item].media:content.attributes.url);     total=total+1;     }     trace(total); } 

but, trace(rssXML.channel.item[item].media:content.attributes.url); is always empty, so how can i read the attribute url from the tag <media> ??? Thanks!

14/02/2011 18:14Top#2

Mr Coder

Member

Joined at: 10 months ago

Post: 16

Thank: 0

Thanked: 0

ok so try this

try rssXML.channel.item[item].namespace("media")::content.@url

09/02/2016 22:32Top#3

TechVP

Member

Joined at: 8 months ago

Post: 1

Thank: 0

Thanked: 0

Here is the information that will get you the closest answer to your request: In your AS code section add this import:

private var media:Namespace = new Namespace("http://search.yahoo.com/mrss/"); 

Then in your function block(s) you can access the media namespace in this way:

var urlString:String = rssXML.media::content.@url[0]; 

media::content uses the media namespace, which is imported above. Now you can access the members like content. Within that is the member url, which can be an indexed array -- so we specifically say @url[0] to obtain the first entry.

If in doubt, you can consult this additional answer: XML AS3 Selecting Image URL Namespace value

Similar articles

Open a folder in finder/explorer from a webpage?

5 years ago - Reply: 2 - Views: 80

How do I escape a reserved word in Actionscript?

5 years ago - Reply: 2 - Views: 198

Save PPS/PPT files as SWF using C#

5 years ago - Reply: 2 - Views: 171

Ways of making a graphic/visual novel in flash

6 years ago - Reply: 3 - Views: 114

Use PhoneGap + HTML5 and an Embedded Flash Movie

5 years ago - Reply: 2 - Views: 96

View word docs and PDF in browser?

5 years ago - Reply: 2 - Views: 52

ActionScript 3 Read JPEG quality

7 years ago - Reply: 2 - Views: 59

Export/Test Movie Issues

5 years ago - Reply: 3 - Views: 39

Flash always on top in Android browser workaround?

5 years ago - Reply: 2 - Views: 149

Sending Json Form from Flash AS3

5 years ago - Reply: 2 - Views: 29

parsing a swf/fla (using php?)

6 years ago - Reply: 2 - Views: 44

Getting high FPS on Flash/AIR games for mobile?

4 years ago - Reply: 2 - Views: 58

vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re