In a particular scenario,we faced a problem with CAML query, returning an error “The property Query contains an invalid value.”.

Our CAML query was:

<Where>
<Contains><FieldRef Name=’Kits’/><Value Type=’Text’>Ray & Martin</Value></Contains>;
</Where>

After lots of tries we came to the solution that only in value’s containing ‘&’ we faced the problem, for other cases it worked fine.

We tried using CDATA, and it worked.

The reason being,a CDATA section is a section of element content that is marked for the parser to interpret as only character data, not markup.

So, our new approach as:

<Where> 
<Contains>   
<FieldRef Name=’Kits’/>     
<Value Type=’Text’>  <![CDATA[Ray & Martin]]></Value></Contains>
</Where>

Advertisements