I wanted to do a case insensitive xpath lookup in my C# .Net application. There was no direct way that i could find to get the job done, but fortunately the workaround ain’t that difficult. Lets consider the following example:
<xml>
<books>
<book id=”1″ name=”Book1″ type=”fiction” />
<book id=”2″ name=”Book2″ type=”nonfiction” />
<book id=”1″ name=”Book1″ type=”FICTION” />
</books>
To request for all fiction books here is the xpath query:
“books/book[translate(@type, ‘ABCDEFGHIJKLMNOPQRSTUVWXYZ’, ‘abcdefghijklmnopqrstuvwxyz’) =’fiction’”
I think you meant (forgot the ]):
“books/book[translate(@type, ‘ABCDEFGHIJKLMNOPQRSTUVWXYZ’, ‘abcdefghijklmnopqrstuvwxyz’) =’fiction’]”
also you would use the select() and pass the expression to select the information in C#