Tim Huffam

Dotting the I and crossing the T of I.T.

  Home  |   Contact  |   Syndication    |   Login
  153 Posts | 0 Stories | 2747 Comments | 653 Trackbacks



Post Categories

Interesting Blogs/Links

XPath statements are case sensitive.  To get around this use the following example to convert all data to lower case before performing the equality check:

/bookstore/book[translate(@category, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = '" + searchtext.ToLower() + "']

Thanks very much to Harish for this!

posted on Thursday, July 6, 2006 11:01 AM


# re: Case insensitive XPath 6/19/2007 5:52 AM kbird
thanks nice work around!

# re: Case insensitive XPath 9/21/2007 1:26 AM Anoop

I am getting an XPAth expression an an input from a text box as a string and then using the string to make an XPAth search. How can I use this tranlate func() there to make my search case insensitive. I am working in C# .Net.

# re: Case insensitive XPath 8/12/2009 2:01 PM Jawad
Thank you, just what I was looking for!

# re: Case insensitive XPath 3/26/2010 11:22 AM Alan Feekery
Thanks, exactly what I was looking for! =D

# re: Case insensitive XPath 4/30/2010 1:31 PM Siva
worked great

# re: Case insensitive XPath 6/9/2010 9:11 AM yrami
Thanks Tim, worked well.

# re: Case insensitive XPath 9/23/2010 11:08 AM vk
<?xml version="1.0"?>
<!-- This file represents a fragment of a bookstore inventory database -->
<bookstore specialty="novel">
<Title>Beginning XML</Title>
<Title>Professional XML</Title>
<Title>Programming ADO</Title>
<Publisher>Microsoft Press</Publisher>

This xpath converts the title to lower case and searches for 'xml' in the Title element and returns all the book Nodes for that title


# re: Case insensitive XPath 9/29/2010 3:29 AM TheHacker
Thanks vk, I was getting problems with retrieving nodesets and converting them to upper-case for string comparison, which you obviously can't do.
Your workaround gets round it by converting each node's value within the [] brackets and so I can evaluate my string inside there.

# re: Case insensitive XPath 6/29/2011 12:12 AM Aaron
Great work, thank you for that.

# re: Case insensitive XPath 12/17/2011 4:15 AM vietnam Train Service
I really loved reading your blog. It was very well authored and easy to understand. Unlike additional blogs I have read which are really not good. I also found your posts very interesting. In fact after reading, I had to go show it to my friend and he enjoyed it as well!

# re: Case insensitive XPath 4/9/2012 10:17 PM Vietnam Railways
Thank you for sharing this article, I will do as instructed. Expect to succeed

Post A Comment