使用 E4X 解析 XML 打印:结果不一致?

发布于 2024-08-21 10:11:24 字数 671 浏览 7 评论 0原文

我正在尝试解析从 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

美煞众生 2024-08-28 10:11:24

好吧,动作脚本中的“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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文