I am running Xpath 2.0 in a Rails project and trying to use the function matches()that it provides like this:
matches()
page = Mechanize.new.get('http://www.example.com').parser page.search("//a[matches(text(),'lagerfordon','i')]").first.text
which causes the following error:
RuntimeError: xmlXPathCompOpEval: function matches not found
What am I doing wrong?
Nokogiri (on which the Engine is built) uses libxml, which supports XPath 1.0 but not XPath 2.0, and therefore there is no function matches.
matches
Using the function, containsyou can match the case:
contains
//a[contains(text(),'lagerfordon')]
, Mechanize Ruby XPath.