Thursday, January 31, 2008

CAML

Lately, I have been working on a WebPart which using the Sharepoint API, retrieves a SharePoint list from the List Library.

The WebPart then generates an ordered A to Z list with categories, anchor links, and searching capability.

Now one of my largest challenges has been filtering the SharePoint list using the API.

One way to query the List is using Collaborative Application Markup Language (CAML).

CAML is an XML based language, used to Customize websites in SharePoint in various ways.

I find the syntax of CAML quite tedious and have yet to figure out a way to generate it dynamically to query my list.

I have spent quite a bit of time understanding the static structure of CAML.

In this situation I'm trying to filter two columns ( Office, Category ).

I can have one or many Offices and Categories.

Before I retrieve the SharePoint list I will pass it the a Dynamic generated CAML query.

At the moment i'm generating the CAML using StringBuilders in an enormous loop! Not my ideal way of doing it, and I know that I can use the XML Document Object to generate the CAML.

So this is what I'm going to begin doing, I will work out a solution of dynamically generating CAML using the XML Document Object. I know that this isn't the only way as there are always many solutions to everything. However using the XML Document object seems like the ideal way of doing it, since CAML is XML Structured.

So my Journey begins, I will be sure to keep posting on my progress.

No comments: