This is a simple question that took me a while to figure out. I know I can just loop through the contents of an XMLList and check manually if a certain child node’s value exists or not; however, I wanted a simple one-liner.
Here’s an example:
I want to find out if the string “JACKPOT” is contained within the child node value of this XMLList:
var list:XMLList = <> <Item> <SubItem>123</SubItem> </Item> <Item> <SubItem>JACKPOT</SubItem> </Item> <Item> <SubItem>123</SubItem> </Item> </>;
E4x code (returns true or false if exists):
list.child("Item").(text().toString() == "JACKPOT").length() != 0