Class XPath (Excel VBA)

The class XPath represents an XPath that has been mapped to a Range or ListColumn object.

Set

To use a XPath class variable it first needs to be instantiated, for example

Dim xph as XPath
Set xph = ActiveCell.XPath

The following procedures can be used to set variables of type XPath: ListColumn.XPath and Range.XPath

Clear

Clears all XPath schema information for the mapped range.

Clear affects the entire range mapped to the XPath object. This method does not clear the data from the cells mapped to the specified XPath. Use the Clear method of the Range object to clear the data from the cells. If the specified XPath is mapped in an XML list, the schema mapping is removed, but the list is not deleted from the worksheet. If the mapped range is a single-cell, the single-cell is removed and the data remains. This method produces an error if any of the following conditions are true:

ActiveCell.XPath.Clear

Map

Returns an XmlMap object that represents the schema map that contains the specified XPath object.

Dim xmlmpMap As XmlMap
Set xmlmpMap = ActiveCell.XPath.Map

Parent

Returns the parent object for the specified object. Read-only.

Repeating

Returns True if the specified XPath object is mapped to an XML list; returns False if the XPath object is mapped to a single cell.

Dim booRepeating As Boolean
booRepeating = ActiveCell.XPath.Repeating

SetValue

Maps the specified XPath object to a ListColumn object or Range collection. If the XPath object has previously been mapped to the ListColumn object or Range collection, the SetValue method sets the properties of the XPath object.

See the IsExportable property of the XMLMap object for a discussion on XPath support in Excel. If the XPath expression is invalid or if the XPath specified has already been mapped, a run-time error occurs. If Excel cannot resolve the namespace, a run-time error occurs. This method produces an error if any of the following conditions are true:

SetValue (Map, XPath, SelectionNamespace, Repeating)

Dim strXPath As String: strXPath = 
ActiveCell.XPath.SetValue Map:=, XPath:=strXPath

Arguments

The following arguments are required:

Map (XmlMap) - The map info that the mapped range will be associated with.

XPath (String) - A valid XPath expression that tells Excel what XML data should appear in this mapped range. The XPath string can also contain valid filters, in which case, only a subset of the data that the XPath points to will ever appear in this mapped range.

The following arguments are optional

SelectionNamespace (XPath) - Specifies any namespace prefixes used in the XPath argument. This argument can be omitted if the XPath object doesn't contain any prefixes, or if the XPath object uses the Microsoft Excel internal prefixes.

Repeating (XPath) - Specifies whether the XPath object is to be bound to a column in an XML list or mapped to a single cell. Set to True to bind the XPath object to a column in an XML list. False forces a non-repeating cell to be created. If the range is greater than a single cell and False is specified, a run-time error occurs.

Value

Returns a String that represents the XPath for the specified object.

Dim strValue As String
strValue = ActiveCell.XPath.Value