I've been experimenting with searching and filtering XML and displaying results and can't seem to google my way to the right answer so...
Is there any way to simplify the expression below so it searches all children of each item without using the 'or' statement? If each item has 50 children, I'm guessing that using 50 'or' statements is not the way to go.
What I'd like to do is search each item and return it if it contains "color" in any of the children, be it name, description...
Any advice would be much appreciated.
Code:
var myXML:XML =
<items>
<item name="item1">
<name>color magic marker</name>
<description>no keyword here.</description>
</item>
<item name="item2">
<name>pen</name>
<description>blah blah</description>
</item>
<item name="item3">
<name>magic marker</name>
<description>color here</description>
</item>
</items>;
trace(myXML.item.( /color/.test(name) || /color/.test(description) ));