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>[email protected] (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!

2 Answers 2

1

http://help.adobe.com/...

@ attribute identifier

Usage

myXML.@attributeName

Identifies attributes of an XML or XMLList object. For example, myXML.@id identifies attributes named id for the myXML XML object. You can also use the following syntax to access attributes: myXML.attribute("id"), myXML["@id"], and myXML.@["id"]. The syntax myXML.@id is recommended. To return an XMLList object of all attribute names, use @*. To return an attribute with a name that matches an ActionScript reserved word, use the attribute() method instead of the @ operator.

var myXML:XML = 
    <item id = "42">
        <catalogName>Presta tube</catalogName>
        <price>3.99</price>
    </item>;

trace(myXML.@id); // 42

In your case:

trace(rssXML.channel.item[item].media:content.@url);
3
  • hello, that gave me an error: Scene 1, Layer 'Layer 1', Frame 1, Line 19 1084: Syntax error: expecting rightparen before colon.
    – DomingoSL
    Feb 14, 2011 at 21:46
  • 1
    It is problem with namespace. You should use following syntax: var media:Namespace = new Namespace(rssXML.namespace("media")); trace(rssXML.media::content.@url);
    – Eugene
    Feb 14, 2011 at 22:28
  • http://help.adobe.com/...
    – Eugene
    Feb 14, 2011 at 22:30
1

Have you tried .attribute("url") I think .attributes() are for all attributes within that element.

Try Reading Traversing XML structures

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.