XPath value lower case or upper case function in C#

XPath function to translate or convert into lower case using two different ways based on version of XPath.

In XPath 2.0 onwards it has function lower-case() or upper-case(). If your environment supports this version of the standard, you can write:

Lower Case:

NodeIter = nav.Select("/Products/Product/name[lower-case(.) ='" + productName +"']")

Upper Case:

NodeIter = nav.Select("/Products/Product/name[upper-case(.) ='" + productName +"']")

However, if your system supports XPath version 1.0. In that case, you can use the translate() function:

Lower Case:

NodeIter = nav.Select("("/Products/Product/name[ (translate(., "
    + "'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), '"
    + productName + '"]");

Upper Case:

NodeIter = nav.Select("("/Products/Product/name[ (translate(., "
    + "'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'), '"
    + productName + '"]");

If you have any question don't forget to ask
Thank you for watching this article

4 comments on “XPath value lower case or upper case function in C#”

  1. Gravatar of urticaria  urticaria
    Posted Tuesday, August 7, 2012 at 3:14:03 AM

    This was really something very special and interesting. Hopefully I can really learn so much from this valuable information. Thanks

  2. Gravatar of hep c treatment  hep c treatment
    Posted Monday, October 15, 2012 at 12:32:10 AM

    Being a programmer by profession, the above information is indeed very useful for me. Thanks for sharing.

  3. Gravatar of hpv men  hpv men
    Posted Thursday, October 18, 2012 at 5:45:13 AM

    You have indeed shared a very informative article related to C sharp. Thanks for sharing.

  4. Gravatar of omega replica  omega replica
    Posted Wednesday, December 12, 2012 at 11:33:13 PM

    I am pleased to get your own distinguished knack of creating that post. You now ensure it is effortless to do to understand in addition to put into practice the idea. Many thanks for any post

Post a comment