1

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.

JD Isaacks
  • 56,088
  • 93
  • 276
  • 422

1 Answers1

2

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

trace(list.toXMLString());
JD Isaacks
  • 56,088
  • 93
  • 276
  • 422
  • Yes, that's a weird Flex debugger issue. If an e4x expression returns just a single node it is there but trace is always empty. –  Jun 18 '09 at 16:24
  • I found if there is no "content" to the xml only the tag and some attributes, then it does not trace out what we expect. I found this out when I was, like you, expecting to see the xml but got blank but list.(@stone == 'Opal').length() still returned the correct amount. – WORMSS Jul 27 '11 at 11:00