E4X:表达式没有返回我期望的结果

发布于 2024-07-17 13:01:51 字数 976 浏览 6 评论 0原文

我有一个 XMLList,我试图从列表中获取一个具有石头属性 == Opal 的列表,但它不起作用,我不明白为什么?

这是代码:

var xml:XML = <bs><variation price="999999999.99" month="OCT" stone="Magic Pet Rock" image="https://www.sussexjewelers.com/birthstone_images/20_PE105-BT.png" style="PE105" gold_color="White" gold_carat="14"/>
<variation price="999999999.99" month="OCT" stone="Opal" image="https://www.sussexjewelers.com/birthstone_images/17_PE105-OP.png" style="PE105-OP" gold_color="Yellow" gold_carat="14"/>
<variation price="33212221.00" month="OCT" stone="Pink Tourmaline" image="https://www.sussexjewelers.com/birthstone_images/16_PE105-PT.png" style="PE105-PT" gold_color="Yellow" gold_carat="14"/></bs>;


var list:XMLList = xml.children();

trace(list) // returns all three variations

list = list.(@stone == 'Opal');

trace(list); // expecting to return the 2nd variation but actually returns nothing.

任何人都可以看出为什么这不能按预期工作吗?

谢谢。

I have an XMLList, I am trying to grab one from the list with a stone attribute == Opal but its not working, I don't understand why?

Here is the code:

var xml:XML = <bs><variation price="999999999.99" month="OCT" stone="Magic Pet Rock" image="https://www.sussexjewelers.com/birthstone_images/20_PE105-BT.png" style="PE105" gold_color="White" gold_carat="14"/>
<variation price="999999999.99" month="OCT" stone="Opal" image="https://www.sussexjewelers.com/birthstone_images/17_PE105-OP.png" style="PE105-OP" gold_color="Yellow" gold_carat="14"/>
<variation price="33212221.00" month="OCT" stone="Pink Tourmaline" image="https://www.sussexjewelers.com/birthstone_images/16_PE105-PT.png" style="PE105-PT" gold_color="Yellow" gold_carat="14"/></bs>;


var list:XMLList = xml.children();

trace(list) // returns all three variations

list = list.(@stone == 'Opal');

trace(list); // expecting to return the 2nd variation but actually returns nothing.

Can anyone see why this is not working as expected?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

土豪 2024-07-24 13:01:51

我在弄清楚之前就发布了这个问题...当我跟踪它时,我需要添加 toXMLString() 。

trace(list.toXMLString());

I postd this question right before I figured it out...I need to add toXMLString() when I trace it.

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