XPathEvalError: Unregistered function for matches() in lxml
As mentioned in the other answer, emphasizing on the other part of the quoted documentation, you can use EXSLT extensions to have a regex match()
function with lxml, for example :
......
ns = {"re": "http://exslt.org/regular-expressions"}
nodes = root.xpath(".//p3[re:match(.,'ABC')]//preceding::p2//p3", namespaces=ns)
how can i use XPath 2.0 functions here with lxml?
You cannot (reference):
lxml supports XPath 1.0, XSLT 1.0 and the EXSLT extensions through libxml2 and libxslt in a standards compliant way.
contains()
is probably the closest you can go in this case:
.//p3[contains(., 'ABC')]//preceding::p2//p3