XPath object (Excel)
Represents an XPath that has been mapped to a Range or ListColumn object.
Remarks
Use the SetValue method to map an XPath to a range or list column. The SetValue method is also used to change the properties of an existing XPath.
Use the Clear method to remove an XPath that has been mapped to a range or list column.
Example
The following example creates an XML list based on the Contacts schema map that is attached to the workbook, and then uses the SetValue method to bind each column to an XPath.
Sub CreateXMLList()
Dim mapContact As XmlMap
Dim strXPath As String
Dim lstContacts As ListObject
Dim lcNewCol As ListColumn
' Specify the schema map to use.
Set mapContact = ActiveWorkbook.XmlMaps("Contacts")
' Create a new list.
Set lstContacts = ActiveSheet.ListObjects.Add
' Specify the first element to map.
strXPath = "/Root/Person/FirstName"
' Map the element.
lstContacts.ListColumns(1).XPath.SetValue mapContact, strXPath
' Specify the element to map.
strXPath = "/Root/Person/LastName"
' Add a column to the list.
Set lcNewCol = lstContacts.ListColumns.Add
' Map the element.
lcNewCol.XPath.SetValue mapContact, strXPath
strXPath = "/Root/Person/Address/Zip"
Set lcNewCol = lstContacts.ListColumns.Add
lcNewCol.XPath.SetValue mapContact, strXPath
End Sub
Methods
Properties
See also
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.