E4X:表达式没有返回我期望的结果
我有一个 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在弄清楚之前就发布了这个问题...当我跟踪它时,我需要添加 toXMLString() 。
I postd this question right before I figured it out...I need to add toXMLString() when I trace it.