views:

21

answers:

0

I need to apply different filters on XML based on different links that are clicked. I'm having trouble filtering results that need to have more than one filter.

One is to check if an attribute exists then I also need another filter that will get the nodes that have that attribute as well as another that contains a specific category.

Here's an example of my code:

fetchXML: function (category) {
$.ajax({
    type: 'GET',
    url: file,
    success: function (data) {
        var filter = '[ATTRIBUTE1], [ATTRIBUTE2~=' + category + ']';

        var $results = $(data).find(root).children(filter);
    }
}

I also need to add another filter where a certain attribute needs to be searched for two words (which can be in any order or any case). If someone could help me out with this as well that would be awesome.

@Ben I guess that would help. ;-) Here's a slimmed down example:

<root>
    <node attribute1="1" attribute2="I love golf"/>
    <node attribute1="33" attribute2="The sport that is my FAVORITE is fishing"/>
    <node attribute2="I love my job"/>
    <node attribute1="33" attribute2="Basketball is my favorite sport all year long"/>
    <node attribute2="I love sunny days"/>
</root>

How would I go about grabbing the two lines above (node 2 and node 4) that both have an attribute of "attribute1" (any value) and that also have both of the words "favorite" and "sport" (any case)?