Posted in InfoPath 2010, SharePoint 2010

SharePoint 2010 >> Retrieve SharePoint List/Library as XML

It’s possible to retrieve a SharePoint Library or List in XML format using a SharePoint URL.  This is especially useful when using secondary data sources in InfoPath and even better when used with a view which can filter data before it is pulled in. One issue I have struggled with is when populating an InfoPath form field, such as a drop-down list box, with a secondary data source.  Attempting to then filter this information causes all sorts of issues and renders the form incapable of being uploaded; I have written about this here.

How To

There are a few steps to follow to getting the XML data for a Library or List from SharePoint.

Finding the Library or List GUID

The first thing to do is to identify the GUID.  The easiest way to find your Library or Lists GUID is to navigate to the Library or List, and click Library (Under Library Tools Tab) → Library Settings.  Check the URL of the settings page and you will see something similar to this:

The text marked in red is your GUID.  You will need to change the text marked in blue:

  • %7B needs to be changed to {
  • %7D needs to be changed to }
  • The %2D represent hyphens (), but I’ve never had to change these.

You will end up with a GUID looking like this:

{276B8F28%2DB501%2D4B6D%2DB714%2DE0225087F7BD}

Finding a View’s GUID

Similarly to above, you must navigate to the Library or List you wish to view as XML.  Click Library (Under Library Tools Tab) → Library Settings → Scroll down to Views and click on the view you wish to find the GUID for.  After clicking the View, copy the URL at the top into notepad and the GUID for this view can found after &View=, as below:

Again, replace the text marked in blue described in the previous section.  You’ll end up with something similar to this:

{0E94047D%2D3A3A%2D40C3%2DAF46%2D1FB79FB2A076}

Getting the XML Data

The URL’s for getting the XML data are:

  • For a SharePoint Library/List, viewing it’s default view:http://sharepoint/subsite/_vti_bin/owssvr.dll?Cmd=Display&List={guid}&XMLDATA=TRUE
  • For a SharePoint Library/List, for a specific view:http://sharepoint/subsite/_vti_bin/owssvr.dll?Cmd=Display&List={guid}&View{guid}&XMLDATA=TRUE

You’ll need to replace sharepoint and subsite with your own SharePoint site details. The guid‘s also need to be replaced with the relative List/Library GUID’s, and a GUID for a specific List/Library view if required.  Once you have built up the URL string you can place this in a web browser to view the XML, as below:

sharepointXMLListExample

One thought on “SharePoint 2010 >> Retrieve SharePoint List/Library as XML

Leave a comment