Wednesday, July 28, 2010

Read XML file on Visual Basic 6

At the first time we must add reference like this image :

image

After that we must add some code on vb form, example :

Private Sub CheckConfigurationFiles()
    Dim strFileConf As String
    Dim fso As FileSystemObject
    Dim strFolSC As String
    Dim strFolDS As String
    Dim strAtoClose As String
    Dim strApp As String
    
       
    strFileConf = "SYNDER_BASIC_Con.xml"
    Set fso = CreateObject("Scripting.FileSystemObject")
    If fso.FileExists(App.Path & "\" & strFileConf) Then
        
        Dim objDOM As MSXML2.DOMDocument40              'Using reference microsoft XML
        Set objDOM = New MSXML2.DOMDocument40
        objDOM.Load App.Path & "\" & strFileConf
        
        'get data parameter, urutan dalam file xml berpengaruh
        strFolSC = objDOM.childNodes(1).childNodes(0).nodeTypedValue
        strFolDS = objDOM.childNodes(1).childNodes(1).nodeTypedValue
        strAtoClose = objDOM.childNodes(1).childNodes(2).nodeTypedValue
        strAppToRun = objDOM.childNodes(1).childNodes(3).nodeTypedValue
End Sub


Have a nice code :D






No comments: