Compartir vía


Objeto XPath (Excel)

Representa un XPath que se ha asignado a un objeto Range o ListColumn .

Comentarios

Use el método SetValue para asignar una expresión XPath a un rango o una columna de una lista. El método SetValue también se usa para cambiar las propiedades de un XPath existente.

Use el método Clear para quitar una expresión XPath asignada a un rango o una columna de una lista.

Ejemplo:

En el ejemplo siguiente se crea una lista XML basada en el mapa de esquema Contactos que está asociado al libro y, a continuación, se usa el método SetValue para enlazar cada columna a un 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

Métodos

Propiedades

Vea también

Soporte técnico y comentarios

¿Tiene preguntas o comentarios sobre VBA para Office o esta documentación? Vea Soporte técnico y comentarios sobre VBA para Office para obtener ayuda sobre las formas en las que puede recibir soporte técnico y enviar comentarios.