Thursday, 18 September 2014

IMAGE PARSING WITH XML AND AJAX



im looking to display an image from an xml document (merchant_image_url), for some reason i can display the url, but not the attribute, any help would be greatly appreciated


my xml



<ROWSET>
<ROW>
<aw_product_id>3129318103</aw_product_id>
<merchant_product_id>5360096034</merchant_product_id>
<merchant_category>Road Bikes - Race</merchant_category>
<aw_deep_link>http://ift.tt/1wIBN37;
<merchant_image_url>http://ift.tt/XMiDKI;
</ROW>
</ROWSET>


and my jquery



function xmlParser(xml) {
$('#load').fadeOut();
//nth-child refers to listed number in xml. 1 for 1st property 4 for 4th property etc
//"propref" refers to the field in the xml which we are asking to look up
$(xml).find("ROWSET ROW").each(function () {
$("#div1").append('<div class="col-md-3">' + $(this).find('product_name').text() + '<br />' + $ (this).find('aw_image_url').attr("url") + '<br /> £' + $(this).find('search_price').text() + '<br />' + '</div></div>');

});

}

No comments:

Post a Comment