Search code examples
xmlxpathparentheses

XPath logical expression


I have a simple expression:

*[local-name() = 'test' and namespace-uri() = 'test1' or namespace-uri() = 'test2']"

This is something like:

 (x and y) or z

How to create the following expression:

x and (y or z)

I am using XPath 2.0


Solution

  • Try:

    *[local-name() = 'test' and (namespace-uri() = 'test1' or namespace-uri() = 'test2')]"
    

    or

    *[local-name() = 'test' and namespace-uri() = ('test1','test2')]"