Achieving attachment url from List by Parsing XML in SharePoint 2010

This SharePoint tutorial explains, how we can get attachment URL from list by parsing XML in SharePoint 2010. Below code can be used to get the attachment URL of any list item by just passing the item ID.

function getAttachmentURL(id , callback)
var requestUri = _spPageContextInfo.webAbsoluteUrl + “/_api/web/lists/getbytitle(‘Announcements’)/items(‘”+id+”‘)/AttachmentFiles” ;

type: “GET”,
url: requestUri,
dataType: “xml”,
success: function(xml){

xmlDoc = (new XMLSerializer()).serializeToString(xml);
xmlDoc = xmlDoc.replace(/d:ServerRelativeUrl/g, ‘ServerRelativeUrl’);

error: function() {
alert(“An error occurred while processing XML file.”);

Check out Best Alternative to InfoPath -> Try Now

You May Also like the Following SharePoint Online Tutorials: