Share via


WorksheetBase.XmlMapQuery Method

Gets a Range object that represents the cells mapped to a particular XPath. Gets nulla null reference (Nothing in Visual Basic) if the specified XPath has not been mapped to the worksheet.

Namespace:  Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel.v4.0.Utilities (in Microsoft.Office.Tools.Excel.v4.0.Utilities.dll)

Syntax

'Declaration
Public Function XmlMapQuery ( _
    xPath As String, _
    selectionNamespaces As Object, _
    map As Object _
) As Range
public Range XmlMapQuery(
    string xPath,
    Object selectionNamespaces,
    Object map
)

Parameters

  • selectionNamespaces
    Type: System.Object

    A space-delimited string that contains the namespaces referenced in the XPath parameter. A run-time error is generated if one of the specified namespaces cannot be resolved.

  • map
    Type: System.Object

    An XmlMap. Specify an XML map if you want to query for the XPath within a specific map.

Return Value

Type: Range
A Range object that represents the cells mapped to a particular XPath; nulla null reference (Nothing in Visual Basic) if the specified XPath has not been mapped to the worksheet.

Remarks

XML features, except for saving files in the XML Spreadsheet format, are available only in Microsoft Office Professional Edition 2003 and Microsoft Office Excel 2003.

Unlike the XmlDataQuery method, the XmlMapQuery method returns the entire column of an XML list, including the header row and the Insert row.

Optional Parameters

For information on optional parameters, see Optional Parameters in Office Solutions.

Examples

The following code example uses the XmlMapQuery method to get the Range of cells mapped to a particular XPath.

This example is for a document-level customization.

Private Sub WorksheetQueryXmlMap()
    Dim path As String = "/order/customer/address" 
    Dim namespaces As String = "xmlns=https://www.contoso.com/orders" 

    Dim range1 As Excel.Range = _
        Me.XmlMapQuery(path, namespaces)

    If range1 Is Nothing Then
        MsgBox("The specified XPath: '" & path & _
            "' has not been mapped to the worksheet.")
    End If 
End Sub
private void WorksheetQueryXmlMap()
{
    string path = "/order/customer/address";
    string namespaces = "xmlns=https://www.contoso.com/orders";

    Excel.Range range1 = this.XmlMapQuery(path, namespaces);

    if (range1 == null)
    {
        MessageBox.Show("The specified XPath: '" + path +
            "' has not been mapped to the worksheet.");
    }
}

.NET Framework Security

See Also

Reference

WorksheetBase Class

Microsoft.Office.Tools.Excel Namespace