7

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

Gary
  • 7,167
  • 3
  • 38
  • 57
Exitos
  • 29,230
  • 38
  • 123
  • 178

2 Answers2

10

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

MrEyes
  • 13,059
  • 10
  • 48
  • 68
  • No. XML Names are case sensitive. And, why quoting M$ documentation? Why not the XML specs? –  Nov 30 '10 at 13:04
  • @Dog Ears: Oh! I didn't see the `show-me-some-ms-documentation` tag... **;)** –  Nov 30 '10 at 13:23
  • 1
    He correctly states that XPath itself is case-sensitive, and then gives an MS specific solution that is perfectly applicable to the combination "C# and xpath" in the question. +1 for a good answer, what's @Alejando's objection? – Jon Hanna Nov 30 '10 at 14:12
2

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'
                 )
      ]
Dimitre Novatchev
  • 240,661
  • 26
  • 293
  • 431