Worksheet.XmlMapQuery method (Excel)

Returns a Range object that represents the cells mapped to a particular XPath. Returns Nothing if the specified XPath has not been mapped to the worksheet.


expression.XmlMapQuery (XPath, SelectionNamespaces, Map)

expression A variable that represents a Worksheet object.


Name Required/Optional Data type Description
XPath Required String The XPath to query for.
SelectionNamespaces Optional Variant 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 Optional Variant Specify an XML map if you want to query for the XPath within a specific map.

Return value



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


XmlMapQuery allows developers to query for the existence of particular maps. It cannot be used to query for a piece of data in a map.

For example, it is valid for a mapped range to exist in which the XPath for that range is "/root/People[@Age="23"]/FirstName". An XmlMapQuery call for this XPath returns the correct range. However, a query for "/root/People[FirstName="Joe"]" expecting to find "Joe" within the above mapped range fails because the XPath definitions for the mapped ranges are different.

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.