Using MS SharePoint as data source : Part 2

Using Sharepoint

In the last post [ Using MS SharePoint as data source : Part 1 ], we went through the understanding of SharePoint in brief. Now that you have all the information, let’s proceed on the scripting part and see how easily we can retrieve and post data to SharePoint.


This a three part series on using sharepoint as data source

Part 1 – Sharepoint and usage Basics
Part 2 – Retrieve data from Sharepoint
Part 3 – Post data to Sharepoint


We are going to use XMLHTTP object to send the request and XML DOM Document to load and parse the response. Let’s consider a SharePoint list Named as “Employee”, which contains Employee data as below. And we need to filter data based on the Grade. 


Sharepoint List


Create Request

The very first thing we need to do is, to create the request with query.

Start with the fixed header

Body Part – use the method GetListItems, which provides all the records in the SharePoint list, provide the list name which you need to connect.

In this case we need to mention “Employee”


Query Part – In order to get the required row(s) based on some condition, we need to mention the condition in the query part of the request. We explained the CAML query in the last post. In this example we would use to filter the record by Grade, let’s say all the employees with Grade as “VP”

The complete Request should like below



 Let’s proceed on to the scripting part now. As mentioned earlier we will use XMLHTTP to post the request to the service. XML DOM (Document Object Model) components include the XMLHTTP object, which provides client-side access to XML documents on remote servers through the HTTP protocol. It exposes a simple API which allows you to send requests and get the response.



Here url should be your SharePoint site service url


 and the request is the one we created above

Once you post the request, you need to get the response out. If you need for reference you can save the response as well. To load the response xml and parse we will use DOM Document

Here, You will get all your data from SharePoint in the object – colItem . Further you can loop through all the items and use as required.  In this case let’s say we need return the ‘first name’ in an array

Below is a generic function for your reference

To use this function


I hope you will find this post useful, in the next post we will see the easiest way of posting date or updating data to the sharepoint.




Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.