2011-02-14 52 views
0

很简单的问题一个XML/RSS的属性,我有这样的:(只有完整的RSS文件的一部分)我无法读取从ActionScript 3的(闪光灯)

<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> 

和我读到<title><pubDate>使用:

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); 
} 

但是,trace(rssXML.channel.item[item].media:content.attributes.url);永远是空的,所以我怎么能读取标签<media>属性网址 ???谢谢!

回答

1

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

@属性标识符

用法

[email protected]

Identifies attributes of an XML or XMLList object. For example, [email protected] 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 [email protected]["id"]. The syntax [email protected] 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([email protected]); // 42 

你的情况:

trace(rssXML.channel.item[item].media:[email protected]); 
+0

你好,这给了我一个错误:场景1,图层 '图层1',第1帧,第19行\t 1084:语法错误:冒号之前rightparen期待。 – DomingoSL 2011-02-14 21:46:21