--- title: "Specifying Boolean Operators in XPath Queries (SQLXML 4.0) | Microsoft Docs" ms.custom: "" ms.date: "03/17/2017" ms.prod: "sql-server-2016" ms.reviewer: "" ms.suite: "" ms.technology: - "dbe-xml" ms.tgt_pltfrm: "" ms.topic: "reference" helpviewer_keywords: - "XPath operators [SQLXML]" - "OR operator" - "Boolean operators" - "XPath queries [SQLXML], Boolean operators" - "operators [SQLXML]" ms.assetid: 9928cff5-62ac-42aa-96bf-2e09a1df0bc3 caps.latest.revision: 25 author: "douglaslMS" ms.author: "douglasl" manager: "jhubbard" --- # Specifying Boolean Operators in XPath Queries (SQLXML 4.0) The following example shows how Boolean operators are specified in XPath queries. The XPath query in this example is specified against the mapping schema contained in SampleSchema1.xml. For information about this sample schema, see [Sample Annotated XSD Schema for XPath Examples (SQLXML 4.0)](../../../relational-databases/sqlxml-annotated-xsd-schemas-xpath-queries/samples/sample-annotated-xsd-schema-for-xpath-examples-sqlxml-4-0.md). ## Examples ### A. Specify the OR Boolean operator This XPath query returns the **\** element children of the context node with the **CustomerID** attribute value of 13 or 31: ``` /child::Customer[attribute::CustomerID="13" or attribute::CustomerID="31"] ``` A shortcut to the **attribute** axis (@) can be specified, and because the **child** axis is the default, it can be omitted: ``` /Customer[@CustomerID="13" or @CustomerID="31"] ``` In the predicate, `attribute` is the axis and `CustomerID` is the node test (TRUE if **CustomerID** is an **\** node, because the **\** node is the primary node for the **attribute** axis). The predicate filters the **\** elements and returns only those that satisfy the condition specified in the predicate. ##### To test the XPath queries against the mapping schema 1. Copy the [sample schema code](../../../relational-databases/sqlxml-annotated-xsd-schemas-xpath-queries/samples/sample-annotated-xsd-schema-for-xpath-examples-sqlxml-4-0.md) and paste it into a text file. Save the file as SampleSchema1.xml. 2. Create the following template (BooleanOperatorsA.xml) and save it in the directory where SampleSchema1.xml is saved. ``` /Customer[@CustomerID="13" or @CustomerID="31"] ``` The directory path specified for the mapping schema (SampleSchema1.xml) is relative to the directory where the template is saved. An absolute path also can be specified, for example: ``` mapping-schema="C:\MyDir\SampleSchema1.xml" ``` 3. Create and use the SQLXML 4.0 Test Script (Sqlxml4test.vbs) to execute the template. For more information, see [Using ADO to Execute SQLXML 4.0 Queries](../../../relational-databases/sqlxml/using-ado-to-execute-sqlxml-4-0-queries.md). Here is the result set of the template execution: ``` ```