E4X select Nodes where descendants can be either A OR B or A && B

timo34ger

New Member
So I have this XML structure:\[code\]<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>\[/code\]Using the following E4X query I get only item "aaa" and item "bbb".\[code\]trace( Items.Item.(descendants("ProductRange").@id == "1" || descendants("ProductRange").@id == "2") );\[/code\]However, I can kind of see why I'm not seeing item "ccc" because it is BOTH id="1" && "2"So not really sure what the correct query should be here, and even if descendants is the correct technique.I don't want to end up doing long additional id="1" && id="2" queries either because I have unlimited combinations of these values ("2" && "3", "1" && "2" && "3") etc..Any thoughts would be most helpful..ThanksSo Patrick solved this with this expression:\[code\]xml.Item.(descendants('ProductRange').(@id=="1" || @id=="2").length()>0);\[/code\]However, taking this one step further, how would dynamically create the @id values, because this will be a changing query depending on user selections.Something like this (but this, but this doesn't work):\[code\]var attributeValues:String = "@id==\"1\" || @id==\"2\" || @id==\"3\" || @id==\"4\"";xml.Item.(descendants('ProductRange').(attributeValues).length()>0);\[/code\]Any more thoughts Patrick.. anyone?Thanks
 
Back
Top