Friday, February 17, 2012

Using owssvr.dll to retrieve List data in XML format

Owssvr.dll is a traditional Remote Procedure Call method to remotely invoke functions in SharePoint. It can be used to retrieve data from SharePoint list as well.

syntax:
http://sharepoint.com/_vti_bin/owssvr.dll?Cmd=Display&List=<<LIST-GUID>>&XMLDATA=TRUE

E.g.
https://intranet.sharepoint.com/_vti_bin/owssvr.dll?Cmd=Display&List={6685db48-013f-4934-8147-b7a6014eccc9}&XMLDATA=TRUE

Other options:
Filter &  View
Append -  FilterField1=<<Field-Internal-Name>>&FilterValue1=<<Value-of-the-field>>
e.g:
FilterField1=Domain&FilterValue1=Sales
View={ViewGuid}


How to get the List GUID?
Go to List settings >> right click "Audience targeting settings" Say "Copy Shortcut". Now you will get something like: https://sharepoint.com/sites/Test/_layouts/ListEnableTargeting.aspx?List={6685db48-013f-4934-8147-b7a6014eccc9}
Highlighted is the GUID.

Output:

Using owssvr.dll to retrieve List data in XML format

Once you get the XML you can use it wherever required.
E.g.:
<script type="text/javascript">
function GetListData()
{
// Get the data from SharePoint List
var reqstring ="http://SharePoint.com/_vti_bin/owssvr.dll?Cmd=Display&List={6685db48-013f-4934-8147-b7a6014eccc9}&XMLDATA=TRUE";
var req = new ActiveXObject("MSXML2.XMLHTTP");
req.open("GET",reqstring,false);
req.send();

//Load response in XML Document
var doc = new ActiveXObject("MSXML2.DOMDocument");
doc.loadXML(req.responseText);
 //Traverse inside doc to retrieve values
 alert(data);
}
</script>

More Examples:
http://msdn.microsoft.com/en-us/library/ms478653.aspx
http://msdn.microsoft.com/en-us/library/ms416599.aspx
http://blogs.msdn.com/b/infopath/archive/2007/01/15/populating-form-data-from-sharepoint-list-views.aspx
http://sharepointfordeveloper.blogspot.co.uk/2012/03/sharepoint-rpc-protocols-examples-using.html



You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Check out these SharePoint products:

No comments :

Post a Comment

Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...