Specifying Boolean Operators in XPath Queries
The following example shows how Boolean operators are specified in XPath queries. The XPath queries in this examples is specified against the mapping schema contained in SampleSchema1.xml. For information about this sample schema, see Sample XPath Queries.
Examples
A. Specify the OR Boolean operator
This XPath query returns the <Customer> element children of the context node with the CustomerID attribute value of ALFKI or ANATR:
/child::Customer[attribute::CustomerID="ALFKI" or attribute::CustomerID="ANATR"]
A shortcut to the attribute axis (@) can be specified, and because the child axis is the default, it can be omitted:
/Customer[@CustomerID="ALFKI" or @CustomerID="ANATR"]
In the predicate, attribute is the axis and CustomerID is the node test (TRUE if CustomerID is an <attribute> node, because the <attribute> node is the primary node for the attribute axis). The predicate filters the <Customer> elements and returns only those that satisfy the condition specified in the predicate.