Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XPath: How do you do a lowercase call in xpath

Tags:

I'm using Firefox's XPath-checker and can't get the syntax right. I have a link:

<a>LinkName</a> 

and I try doing:

//a[lower-case(child::text())='linkname'] 

but I have a syntax error. What am I doing wrong?

Thanks

like image 456
Guy Avatar asked Dec 27 '09 08:12

Guy


People also ask

Does XPath contain case sensitive?

The xpath function contains() is case-insensitive, so that may be a way out.

Which XPath function would you use to transform character to uppercase?

XPath/XQuery upper-case function.


1 Answers

There is no function called lower-case in XPath 1.0 which is the version of XPath used in Firefox.

You need to use the ugly translate function instead:-

  translate(text(), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') 

...but of course you would need to extend this if you need coverage of a wider character-set.

like image 116
AnthonyWJones Avatar answered Sep 20 '22 16:09

AnthonyWJones