$.parseJSON with multiple find() - kind of using AND condition



I'm parsing an XML string using $.parseXML() API. This the following code that I'm using:



success:function(data)
{
$(data).find('TabName:contains("Current year")').each(function(){
$(this).parent().find('IndexEntry:contains("A")').each(function(){
console.log($(this).text());
});
});
}


This is working fine, but I was wondering if I can somehow reduce the lines of code. I'm trying to put a condition TabName="Current Year" AND IndexEntry="A". So is there something like:



$(data).find('TabName:contains("Current year")').find('IndexEntry:contains("A")')


that would put the conditions in a single statement?


UPDATE


I did get to a point where I was able to use



$(data).find('TabName:contains("Current year")', IndexEntry:contains("A")')


but that just used the OR condition instead of AND. This makes me assume that there must be another syntax for AND condition.


No comments:

Post a Comment