Home > Software, Web > Discover CAML by examples

Discover CAML by examples


CAML is the SQL of SharePoint. If you will access SharePoint through its web services you will definately need to be familiar to a certain degree with CAML. You can read the documentation from MSDN, but I will tell you how to learn it through examples. And actually to create your own examples.
There are a few CAML builders out there, but if you know how to use SharePoint, you have a basic one hidden in there.
Let’s take it step by step.

  1. Go to your SharePoint
  2. Create a list
  3. Create a view for the list (for the sake of simplicity let’s name it My View)
  4. Choose the conditions that you’re interested in for the query, let’s say all the items modified today, and save the view.
    View filter in SharePoint

    View filter in SharePoint

  5. Go to the list settings and save the list as a template
    Save list as template in SharePoint

    Save list as template in SharePoint


    List template is saved

    List template is saved

  6. Go to the template list library
    List template gallery

    List template gallery

  7. Download the template
  8. The template is actually a zip file. Rename it from mylist.stp to mylist.zip and extract the manifest.xml file from it.
  9. Now open the XML file (with FireFox) and go to the element /ListTemplate/UserLists/List/Metadata/Views/View[@DisplayName = 'My View'](the first /ListTemplate/UserLists/List/Metadata/Views/View for which the attribute DisplayName is My View). Under this element you will find a Query element. This is what you need, your CAML query.

And that manifest.xml file is also the source of some other useful stuff like the internal name of the fields (the StaticName attribute of the /ListTemplate/UserLists/List/Metadata/Fields/Field elements).

Categories: Software, Web Tags:
  1. No comments yet.
  1. September 23, 2008 at 9:25 pm

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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: