The function of the following code example is to read the contents of an XML file in Excel by using VBA code.
Dim rst as ADODB. Recordset
Dim Stcon As String, Stfile as String
Dim I as Long, J as Long
Set rst = New ADODB. Recordset
Stfile = "C:dzwebs.xml"
Stcon = "provider=mspersist;"
. CursorLocation = adUseClient
. Open Stfile, Stcon, adOpenStatic, adLockReadOnly, adCmdFile
Set. ActiveConnection = Nothing
For j = 0 to I-1
. Cells (1, J + 1). Value = rst. Fields (j). Name
. Range ("A2"). CopyFromRecordset rst
Set rst = Nothing