So, I have this XML structure:
<Items> <Item name="aaa"> <ProductRanges> <ProductRange id="1" /> </ProductRanges> </Item> <Item name="bbb"> <ProductRanges> <ProductRange id="2" /> </ProductRanges> </Item> <Item name="ccc"> <ProductRanges> <ProductRange id="1" /> <ProductRange id="2" /> </ProductRanges> </Item> </Items>
Using the following E4X request, I get only the "aaa" element and the "bbb" element.
trace( Items.Item.(descendants("ProductRange") .@id == "1" || descendants("ProductRange") .@id == "2") );
However, I can see why I do not see the ccc element because it is BOTH id = "1" && & "2"
So Iβm not quite sure what the correct request should be here, and even if the descendants are the right technique.
I donβt want to end up doing a long extra id = "1" && & & id = "2" either because I have unlimited combinations of these values ββ("2" & "3", "1" & "2" & "3"), etc.
Any thoughts would be most helpful.
thanks
So Patrick solved this with this expression:
xml.Item.(descendants('ProductRange').(@id=="1" || @id=="2").length()>0);
However, taking this step further, it would be like dynamically creating @id values, because this will be a changing query depending on user selections.
Something like this (but this, but this does not work):
var attributeValues:String = "@id==\"1\" || @id==\"2\" || @id==\"3\" || @id==\"4\""; xml.Item.(descendants('ProductRange').(attributeValues).length()>0);
Any thoughts on Patrick .. anyone?
thanks