Nick Grattan's Blog

About Microsoft SharePoint, .NET, Natural Language Processing and Machine Learning

More SharePoint List Web Service Calls

with 4 comments

In this post I showed how the SharePoint Web Services can be used to get a list of the lists in a SharePoint site. The code in this post shows how, once you have the GUID associated with a list, you can then retreive all the items from the list.

The method ‘FillListItems’ is passed the GUID for a SharePoint list and returns the list of items in the SharePoint list:

public void FillListItems(Guid g)


   XmlDocument doc = new System.Xml.XmlDocument();


   XmlNode listQuery = doc.SelectSingleNode(“//Query”);

   XmlNode listViewFields = doc.SelectSingleNode(“//ViewFields”);

   XmlNode listQueryOptions = doc.SelectSingleNode(“//QueryOptions”);

   XmlNode items = lst.GetListItems(g.ToString(), string.Empty,

      listQuery, listViewFields,

      string.Empty, listQueryOptions, null);

The Web Service method “GetListItems” can be used to return items from a list based on a list selection (‘listQuery’), a field selection (‘listViewFields’) and a list of options (‘listQueryOptions’). In this case all fields and all items are returned. The method returns a XmlNode list containing the items and the fields for these items. Each item is returned as a row element with the fields returned as attributes:

<rs:data ItemCount=1 xmlns:rs=urn:schemas-microsoft-com:rowset>

  <z:row ows_Attachments=0

         ows_LinkTitle=Get Started with Windows SharePoint Services!

         ows_Modified=2007-07-13 11:50:10




         ows_Title=Get Started with Windows SharePoint Services!

         ows_ID=1 ows_owshiddenversion=1



         ows_Created_x0020_Date=1;#2007-07-13 11:50:10

         ows_Created=2007-07-13 11:50:10



         xmlns:z=#RowsetSchema />


Because SharePoint 2007 allows a list to contain items with different content types, the items in a list may have different fields.

Written by Nick Grattan

July 14, 2007 at 12:31 pm

4 Responses

Subscribe to comments with RSS.

  1. For a demo web part page that uses the Data View to access this web service, see

    Select any list on the left to get the list and field details on the right.

    Ian Morrish

    July 14, 2007 at 8:32 pm

  2. Ian, thanks for the link – the demo looks very good. Nick


    July 16, 2007 at 11:58 am

  3. It was very use full


    October 22, 2008 at 9:50 am

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: