From this very similar question, one of the answers, by kjhughes, offers these solutions :
XPath 2.0 Solutions
- Use lower-case():
/html/body//text()[contains(lower-case(.),'test')]
- Use matches() regex matching with its case-insensitive flag:
/html/body//text()[matches(.,'test', 'i')]
So taking the first approach (i.e. lower-case()) with your examples:
//a[contains(lower-case(@title), "(' + lower-case(args.Code) + ')")]
//a[lower-case(@title)=\'' + lower-case(args.Code) + '\']
Update
From this answer:
upper-case()
and lower-case()
are XPath 2.0 functions. Chances are your platform supports XPath 1.0 only1
Try the first solution (as suggested in the answer by Tomalak):
//a[contains(translate(@title, \'ABCDEFGHIJKLMNOPQRSTUVWXYZ\', \'abcdefghijklmnopqrstuvwxyz\'), "(translate(' + args.Code + ', \'ABCDEFGHIJKLMNOPQRSTUVWXYZ\', \'abcdefghijklmnopqrstuvwxyz\')")]
//a[translate(@title, \'ABCDEFGHIJKLMNOPQRSTUVWXYZ\', \'abcdefghijklmnopqrstuvwxyz\')=translate(\'' + args.Code + '\', \'ABCDEFGHIJKLMNOPQRSTUVWXYZ\', \'abcdefghijklmnopqrstuvwxyz\') ]
Unfortunately, this requires knowledge of the alphabet the text uses. For plain English, the above probably works, but if you expect accented characters, make sure you add them to the list.1
1https://stackoverflow.com/a/1625859/1575353