Sarim Javaid Khan
Sarim Javaid Khan

Reputation: 830

Xpath: string functions not working fine

I am new to xpath and have been wandering on the www for a long time to get the answer. Found some links but couldn't get the answer.

I have the following xpath for a particular scenario and it is working fine

//li[contains(@class,'category_')]/a[contains(@href,'suits')]

Now when I tried to do the above thing using string function for learning purpose, it is not working. I tried the following xpath as the alternative.

//li[contains(@class,'category_')]/a[contains(@href,lower-case("SUITS"))]
//li[contains(@class,'category_')]/a[contains(@href,lower-case('SUITS'))]

What am I doing wrong here? Please help.

Upvotes: 0

Views: 137

Answers (1)

Martin Honnen
Martin Honnen

Reputation: 167716

XPath 1.0 was specified in 1999 and defines the contains function. XPath 2.0 was specified in 2007 and defines the lower-case function. The latest version is XPath 3.0. If you want to use the lower-case function then you need to use an XPath 2.0 or 3.0 implementation or alternatively an XQuery 1.0 or 3.0 implementation as XPath is basically a subset of XQuery. I suspect that you are using an XPath 1.0 implementation and simply get an error that the function lower-case is not known.

Upvotes: 2

Related Questions