--- title: "Executing XPath Queries (SQLXMLOLEDB Provider) | Microsoft Docs" ms.custom: "" ms.date: "03/16/2017" ms.prod: "sql-server-2016" ms.reviewer: "" ms.suite: "" ms.technology: - "dbe-xml" ms.tgt_pltfrm: "" ms.topic: "reference" helpviewer_keywords: - "SQLXMLOLEDB Provider, executing XPath queries" - "queries [SQLXML], SQLXMLOLEDB Provider" - "Base Path property" - "XPath queries [SQLXML], SQLXMLOLEDB Provider" - "Mapping Schema property" ms.assetid: 19063222-dc9c-48ae-a55f-778103674a9e caps.latest.revision: 30 author: "douglaslMS" ms.author: "douglasl" manager: "jhubbard" --- # Executing XPath Queries (SQLXMLOLEDB Provider) This example illustrates the use of the following SQLXMLOLEDB Provider-specific properties: - **ClientSideXML** - **Base Path** - **Mapping Schema** In this sample ADO application, an XPath query (root) is specified against an XSD mapping schema (MySchema.xml). The schema has a **\** element with **ContactID**, **FirstName**, and **LastName** attributes. In the schema, default mapping takes place: an element name maps to the table with the same name, and attributes of simple type map to the columns with the same names. ``` ``` The Mapping Schema property provides the mapping schema against which the XPath query is executed. The mapping schema can be an XSD or XDR schema. The Base Path property provides the file path to the mapping schema. The ClientSideXML property is set to True. Therefore, the XML document is generated on the client. In the application, an XPath query is specified directly. Therefore, the XPath dialect {ec2a4293-e898-11d2-b1b7-00c04f680c56} must be included. > [!NOTE] > In the code, you must provide the name of the instance of [!INCLUDE[ssNoVersion](../../../includes/ssnoversion-md.md)] in the connection string. Also, this example specifies the use of the [!INCLUDE[ssNoVersion](../../../includes/ssnoversion-md.md)] Native Client (SQLNCLI11) for the data provider which requires additional network client software to be installed. For more information, see [System Requirements for SQL Server Native Client](../../../relational-databases/native-client/system-requirements-for-sql-server-native-client.md). ``` Option Explicit Sub main() Dim oTestStream As New ADODB.Stream Dim oTestConnection As New ADODB.Connection Dim oTestCommand As New ADODB.Command oTestConnection.Open "provider=SQLXMLOLEDB.4.0;data provider=SQLNCLI11;data source=SqlServerName;initial catalog=AdventureWorks;Integrated Security= SSPI;" oTestCommand.ActiveConnection = oTestConnection oTestCommand.Properties("ClientSideXML") = True oTestCommand.CommandText = "root" oTestStream.Open oTestCommand.Dialect = "{ec2a4293-e898-11d2-b1b7-00c04f680c56}" oTestCommand.Properties("Output Stream").Value = oTestStream oTestCommand.Properties("Base Path").Value = "c:\Schemas\SQLXML4\XPathDirect\" oTestCommand.Properties("Mapping Schema").Value = "mySchema.xml" oTestCommand.Properties("Output Encoding") = "utf-8" oTestCommand.Execute , , adExecuteStream oTestStream.Position = 0 oTestStream.Charset = "utf-8" Debug.Print oTestStream.ReadText(adReadAll) End Sub Sub Form_Load() main End Sub ```