Sunday, June 17, 2012

Contoh Memparsing XML Attributes

Private Sub Command1_Click()

Dim fso As Object
Dim sDir As String
Dim doc As Object
Dim oFile As Object

Set fso = CreateObject("Scripting.FileSystemObject")
sDir = "C:\work"
Set doc = CreateObject("Msxml2.DOMDocument")
doc.async = False
For Each oFile In fso.GetFolder(sDir).Files
Debug.Print "looking at", oFile.Name
Debug.Print "will load", oFile.Path
If doc.Load(oFile.Path) Then
Debug.Print "successfully loaded", oFile.Name
End If
Next
Set ndlEventId = doc.documentElement.selectNodes("//*")
For i = 0 To ndlEventId.length - 1
Debug.Print ndlEventId(i).nodeName & " :: " & ndlEventId(i).Text
If ndlEventId(i).Text = "" Then
s = ndlEventId(i).nodeName
Debug.Print s
Set attrvalue = doc.getAttribute(s)
Debug.Print attrvalue
End If
Nex
End Sub