in

SharePoint Blogs

The Best Place for SharePoint-related Blogs

The Dean's Office

Don't forget: Web Services/SOAP isn't the only path to XML from SharePoint

<reposted from May 18, 2004> 

A technique we used extensively in STS still applies to WSS: How to get data from your SharePoint lists in XML format. It's actually quite simple, and you don't need to use web services to get it.

WSS supports a number of protocols to interact with the data. SOAP and WEBDAV immediately come to mind for most of you, but you may be forgetting the elusive URL Protocol (GET). Luckily for you, it's simple to use, and returns data in the MS-standard rowset stream format.

Rather than go into a bunch of detail, let's put ourselves to work, shall we? Follow along with these steps, and you'll be pleased with the results, I'm certain. Smile

  1. Determine the GUID of a list whose data you need in XML.
    • Navigate to the allitems.aspx view of the list in question
    • Click the "Modify Settings and Columns" link on the left side
    • Copy the List's GUID (including curly braces) from the address bar
  2. Construct the URL to retrieve the list's data in XML format (it's case sensitive, be careful!)
    • The requested object is http://servername/sitename/_vti_bin/owssvr.dll
    • The object will expect three parameters: Cmd, List and XMLDATA (case sensitive)
    • Since we're displaying items (in XML format), the value of the Cmd parameter should be Display
    • We want to grab the list whose GUID we determined in step one; the value of the List parameter is this GUID (including curly braces)
    • Of course, we want XML data to be returned; the value of the XMLDATA parameter will be TRUE
    • Putting this together, we get a URL that looks like this:
    • http://server/site/_vti_bin/owssvr.dll?Cmd=Display&List={E1D9FED5-2531-413F-8C0F-CAA5C6280E51}&XMLDATA=TRUE
  3. Sit back and marvel at how easy it is to get a rowset out of SharePoint without using the Object Model or the Web Services. You can point a Data View web part to this URL and grab data from another SharePoint site without adding the whole site to your DV catalog listing.

You may find that it doesn't return EVERY field. That's right: It returns fields that are defined in the default "allitems" view of that particular list. If you want more fields, you have two choices:

  1. Modify the allitems.aspx view to show more fields (easy)
  2. Pass an additional URL parameter, View, with the GUID value of the view whose fields you want to return (a little more involved/tedious)

Did you like this tip? Comment!

Comments

 

Cassie said:

One thing to note is that when you retrieve the guid from the browser it already has the curly braces and hyphens in html friendly form. You can take the string and put it directly in the List url parameter.  List=%7BED640BE4%2D7D8C%2D4F8D%2D882A%2D230EE7D334C5%7D

June 22, 2007 9:27 AM
 

Dave Christianson said:

Hey, here's hoping someone is reading this.  This is exactly what I need, however, I want to access the list of document libraries on my site.  I don't see anywhere to do that in SP designer.  Would also be nice to be able to add columns to the document library list, but I suppose that's asking too much.

Thanks for any help.

June 22, 2007 3:54 PM
 

Links (6/24/2007) « Steve’s SharePoint Stuff said:

Pingback from  Links (6/24/2007) &laquo; Steve&#8217;s SharePoint Stuff

June 24, 2007 7:52 PM
 

Sharepoint link love 6-25-2007 at Virtual Generations said:

Pingback from  Sharepoint link love 6-25-2007 at  Virtual Generations

June 25, 2007 2:05 AM
 

Breton Slivka said:

If you are using a dataview webpart and want the document libraries list, you can use this datasource string:

<DataSources><asp:SiteMapDataSource SiteMapProvider="SPNavigationProvider" ShowStartingNode="False" id="QuickLaunchSiteMap1" StartingNodeUrl="sid:1025" runat="server">

</asp:SiteMapDataSource></DataSources>

The xml format is not the rowset format, so watchout- This returns the whole sitemap. You can take your document library list from a branch on this xml.

July 2, 2007 12:47 AM
 

Breton Slivka said:

If you are using a dataview webpart and want the document libraries list, you can use this datasource string:

<DataSources><asp:SiteMapDataSource SiteMapProvider="SPNavigationProvider" ShowStartingNode="False" id="QuickLaunchSiteMap1" StartingNodeUrl="sid:1025" runat="server">

</asp:SiteMapDataSource></DataSources>

The xml format is not the rowset format, so watchout- This returns the whole sitemap. You can take your document library list from a branch on this xml.

July 2, 2007 12:47 AM
 

bathroom vanities said:

July 31, 2007 9:54 AM
 

bathroom vanities said:

July 31, 2007 9:54 AM
 

bathroom faucets said:

August 2, 2007 2:21 PM
 

bathroom sinks said:

August 3, 2007 5:37 PM
 

bathroom vanity cabinet said:

August 4, 2007 11:54 AM
 

bathroom vanity said:

August 4, 2007 7:10 PM
 

bazztrap said:

Does not do it for moss

August 15, 2007 1:31 PM
 

Manish MISTRY said:

Excellent Tip! Probably this is what I wasted my whole yesterday looking for!

Thanks a lot!

November 20, 2007 7:23 PM
 

Alberto said:

It should be the best way to access WSS data, shall we call it REST mode ?

On many lists in my WSS3 site I have no response from owssvr.dll . In WSS log I find (example):  unexpected C++ exception: [INDEXERR] Illegal Index (4294967295) for collection with 9 elements .

June 25, 2008 9:46 AM

Leave a Comment

(required )  
(optional )
(required )  
Add

Need SharePoint Training? Attend a SharePoint Bootcamp!

Posts (c) their respective authors. Everything else (c) 2007 SharePoint Experts