Collaborative Application Markup Language (CAML )

Collaborative Application Markup Language (CAML )

Collaborative Application Markup Language (CAML) is the XML-based language that is used to build and customize Web sites based on SharePoint Team Services.  CAML can be used to provide schema definition to the Web site about how the site looks and acts, define views and forms for data and page rendering or execution, act as a rendering language that performs functions in the DLL like pulling a value from a particular field and others. 

The focus is to pull required information from a SharePoint site. The code is as under: 

SPSite sp = new SPSite(“site URL”);

SPWeb Website = sp.OpenWeb();

SPList DocLib = Website.Lists[“Doc Library Name”]; 

Suppose that we want to get the list of all the documents based on criteria that the value of Column “IsData” is 0. Then, the query will be like  

SPQuery SelectQuery = new SPQuery(DefaultView); //creating a query for the default view 

SelectQuery.Query = “<Where><Eq><FieldRef Name=’IsData’/><Value Type=’Text’>0</Value></Eq></Where>”; //select query 

SPListItemCollection SelectedDoc = DocLib.GetItems(SelectQuery); // getting list of files returned by select query 

int a = SelectedDoc.Count; // gives the number of documents selected 

You can use string.Format to write the query.

You can get all the fields of the rows by using

DataTable as under: DataTable table = docLib.GetItems(SelectQuery).GetDataTable(); 


One or more field types are not installed properly. Go to the list settings page to delete these fields. 


One reason can be column name column don’t match the internal column name. Like the column name ‘SO#’ may change by SharePoint to an other name like ‘SO_XXX’. 


One simple way is to find the internal name of the column by opening the source of the web page where one enters the value of the document before uploading it to the document library. 

Other is to use U2U CAML Query Builder and use it to graphically write the CAML query.



  1. Bramley said


    I always wondered. CAML- is xml based language. Am I correct to say you create all your code in visual studio. If so how do you deploy ur code to sharepoint.

    I have a scenario where I want to pull data from different sites in different collection (like using cross link queries). How do u deploy this code to MOSS. Is there step by step tutorial online.

  2. farhanfaiz said

    According to my understanding, you can create a console application and using object model try to accomplish your task.

    I usually write Event Handlers but I think that this may not fit in your scenario.



RSS feed for comments on this post · TrackBack URI

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: