I have the following XML format and would like to get the list of markers for each category using jQuery.
<categories>
<category id="1">
<marker />
<marker />
<marker />
</category>
<category id="2">
<marker />
<marker />
<marker />
</category>
<category id="3">
<marker />
<marker />
<marker />
</category>
</categories>
I am loading the XML correctly using jQuery with an AJAX call and when I use jQuery.find().each I am getting anywhere. Am I doing it wrong?
$(data).find('category[id=1] > marker').each(function() {}
$(data).find('categories category[id=1] > marker').each(function() {}
Your first solution would be correct, except that you’re missing the closing
);.Example: http://jsfiddle.net/vyFeZ/