3

the caml query bellow don't return the correct result :

<Where><Eq><FieldRef Name='ParentLink' /><Value Type='Text'>ⵜⴰⵎⴰⵡⴰⵙⵜ</Value></Eq>  </Where>

i think the problem is due to the unicode charchter that i use to search. there is a solution to escape it ?

2 Answers 2

4

You need to surround the data with a CDATA tag:

<Value Type="Text"><![CDATA["ⵜⴰⵎⴰⵡⴰⵙⵜ"]]></Value>
2
  • Hello thank you for answering, Unfortunately CDATA tag does'nt resolve my problem. string caml = @"<Where><Eq><FieldRef Name='ParentLink' /><Value Type='Text'><![CDATA[ⵜⴰⵎⴰⵡⴰⵙⵜ]]></Value></Eq></Where>"; i note that my text is in Tifinagh. Thanks.
    – user19096
    Aug 23, 2013 at 14:30
  • You have to use quotes too, per the example.
    – Paul Leigh
    Aug 23, 2013 at 18:50
0

Try encoding the given string before passing it to the CAML query:

string EncodeForCAML(string s)  
{           
    StringBuilder sb = new StringBuilder();  
    for (int i = 0; i < s.Length; ++i)  
    {  
        char ch = s[i];  
        if (char.IsLetterOrDigit(ch))  
            sb.Append(ch);  
        else 
            sb.AppendFormat("&#{0};", Convert.ToInt32(ch));  
    }  
    return sb.ToString();  
}  

SOURCE

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.