So, I have a list of nodes in a dynamic XML that is cached on a server. Using Ajax, I loop through the particular nodes to return a string each time:
XML:
<?xml version="1.0"?>
<Products>
<Product>
<ItemName>String</ItemName>
</Product>
<Product>
<ItemName>String</ItemName>
</Product>
<Product>
<ItemName>String</ItemName>
</Product>
<Products>
jQuery:
$.ajax({
type: "GET",
url: '/services/Scraper.aspx',
success: function(data) {
$(data).find('Product').each(function() {
var itemSrc = $(this).find('ItemName').text();
});
}
});
How do I go about injecting each one of those strings in order into my H2 tag below (assuming there can be more than three XML nodes and/or HTML H2 tags?
<div class="itemLoc">
<h2></h2>
</div>
<div class="itemLoc">
<h2></h2>
</div>
<div class="itemLoc">
<h2></h2>
</div>
Any help would be great! Thanks!