xpath逻辑运算符优先级为AND和OR,不带括号

xpath逻辑运算符优先级为AND和OR,不带括号,xpath,operator-precedence,Xpath,Operator Precedence,我正在编写一个xpath表达式来实现这一点: //parent[(childA[contains(.,"foo")] or childB[contains(.,"foo")]) AND (childA[contains(.,"bar")] or childB[contains(.,"bar")])] 选择一个其子级(childA或childB或同时包含childA和childB)同时包含字符串“foo”和“bar”的父级 我不确定前后括号和是否正确使用。xpath可以有这样的括号吗 提前谢谢

我正在编写一个xpath表达式来实现这一点:

//parent[(childA[contains(.,"foo")] or childB[contains(.,"foo")]) AND (childA[contains(.,"bar")] or childB[contains(.,"bar")])]
选择一个其子级(childA或childB或同时包含childA和childB)同时包含字符串“foo”和“bar”的父级

我不确定前后括号和是否正确使用。xpath可以有这样的括号吗

提前谢谢

见。特别是:

Parentheses may be used for grouping.

注意:上述语法的作用是优先顺序为
(最低优先级优先):
或
和
=, !=
运算符都是左关联的。例如,3>2>1是
相当于(3>2)>1,其计算结果为false。

Re 3>2>1,这仅适用于XPath 1.0。在XPath2.0中,不再允许使用此表达式。(问题并不是专门针对XPath 1.0)。
NOTE: The effect of the above grammar is that the order of precedence is 
(lowest precedence first):

    or 
    and
    =, !=
    <=, <, >=, >

and the operators are all left associative. For example, 3 > 2 > 1 is 
equivalent to (3 > 2) > 1, which evaluates to false.