使用 E4X 解析 XML 打印:结果不一致?
我正在尝试解析从 Twitter 的 Restful API 检索的推文 XML 文件(http://apiwiki.twitter.com/Twitter-REST-API-Method:-statuses-user_timeline)。问题是,当我使用以下命令打印它时:
tweetTextArea.text += xml..text;
我收到了推文。然而,当我尝试以下操作时,我得到的只是数字:
// Print all tweets.
for (var tweet : * in xml..text) {
tweetTextArea.text += tweet;
}
我对此感到非常困惑。我在 WWW 上搜索过,试图找到一个像样的综合 AS3 教程,特别是关于 E4X 的教程,但没有找到任何对我有帮助的东西。我确信这是一个小问题。
怎么了?
我可以在 for-each 循环中迭代推文,还是必须诉诸使用标准 for 循环?
我正在 MXML 文件中使用代码,如有必要,将使用完整源代码进行更新。
I'm trying to parse an XML file of tweets as retreived from Twitter's restful API (http://apiwiki.twitter.com/Twitter-REST-API-Method:-statuses-user_timeline). The issue is, when I print it using:
tweetTextArea.text += xml..text;
I get the tweets. However, when I try the following, I get just numbers:
// Print all tweets.
for (var tweet : * in xml..text) {
tweetTextArea.text += tweet;
}
I am seriously perplexed by this. I have scoured the WWW to try and find a decent comprehensive AS3 tutorial and specifically on E4X but haven't found anything that's helping me. I'm sure it's a minor issue.
What is happening?
Can I iterate through the tweets in a for-each loop or do I have to resort to using a standard for loop?
I'm using the code inside a MXML file, and will update with full source if necessary.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,动作脚本中的“for ... in”和“for every ... in”之间有很大的区别。您想要做的事情可能会要求“foreach”,因为它会迭代对象/集合的项目而不是属性,就像“for”那样。
了解有关 actionsctipt 中循环的更多信息:LiveDocs
Ok, there's a big difference between "for ... in" and "for each ... in" in actionscript. What you're trying to do would probably ask for a "for each" as it iterates through the items of an object/collection rather than properties, like "for" does.
Read more on loops in actionsctipt on: LiveDocs