can somebody help me select the url from this XML document where the ID = 2. via ajax.
<images>
<image id=0>
<url>images/pic.jpg</url>
</image>
<image id=1>
<url>images/pic.jpg</url>
</image>
<image id=2>
<url>images/pic.jpg</url>
</image>
</images>
I am guessing something like this... But currently it is displaying all the entries in the xml. i only want it to load one image, how do i do this please?
$.ajax({
type: "GET",
url: "images.xml",
dataType: "xml",
success: function(xml) {
$(xml).find('image').each(function(){
var id = $(this).attr('id'); //maybe something here?????
var url = $(this).find('url').text();
$('.loading').html('<img src='+url+' />');
});
}
});