pythonxpathlxmllibxml2xpath-2.0

Library that supports XPath 2.0 in Python


Is it possible to use XPath 2.0 functions like starts-with(), ends-with() and contains() in Python? I was trying to use lxml and defusedxml, but unfortunately they do not support any of these functions.

I know I can use substring() or matches() for workaround, but I have really complicated case, so it would be nicer to deal with more readable functions.

Any lib that supports XPath 2.0 spec?


Solution

  • saxonpy is based on Saxon He and supports Xpath 2.0. You can check the github repo for some examples to get you started:

    https://github.com/tennom/saxonpy