I\'m currently making a xpath search, I\'ve got the the search working but I need to make it case insensitive. The xml file I\'m using is 1.0 which from my research means I\
The currently accepted answer is flawed -- because nothing guarantees that the second argument of contains() is already converted to lower case.
Also, it uses '$search' -- and this is literally the string "$search" -- not the variable $search.
Here is a correct solution:
//channel/item
[contains(translate(.,
'ABCDEFGHJIKLMNOPQRSTUVWXYZ',
'abcdefghjiklmnopqrstuvwxyz'),
translate($txtSearch,
'ABCDEFGHJIKLMNOPQRSTUVWXYZ',
'abcdefghjiklmnopqrstuvwxyz')
)
]
The corresponding XPath 2.0 expression:
//channel/item[contains(lower-case(.), lower-case($txtSearch))]
Update:
Based on this solution, @alain.janinm has corrected his answer.