jQuery XML Traversing
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] > mar开发者_如何学Pythonker').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/
$(data).find('category[id=1] > marker').each(function() {
// do something
});
A sample from my code , replace the names with your code
// process your code inside the loops
$(callback).find('CartClass Shipments Shipment Items Item').each(function() {
$(callback).find('EstimatedArrivalDate Item').each(function() {
});
});
精彩评论