Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to ignore case using xpath and c#?

Just wondered if its possible to ignore case with c# and xpath when searching an xml document?

like image 410
Exitos Avatar asked Nov 30 '10 12:11

Exitos


2 Answers

The bad news is that Xpath is case sensitive, however there are ways to get around this. Have a look at the following MSDN blog:

http://blogs.msdn.com/b/shjin/archive/2005/07/22/442025.aspx

like image 192
MrEyes Avatar answered Nov 08 '22 23:11

MrEyes


XPath is case sensitive.

If you would allow any case combination of characters in a name (bad decision!), an XPath expression successfully dealing with this might look like:

/a/b/*['anycasename' 
      = translate(name(), 
                 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
                 'abcdefghijklmnopqrstuvwxyz'
                 )
      ]
like image 30
Dimitre Novatchev Avatar answered Nov 08 '22 23:11

Dimitre Novatchev