Overblog Tous les blogs Top blogs Technologie & Science Tous les blogs Technologie & Science
Editer l'article Suivre ce blog Administration + Créer mon blog
MENU

VBS: Read and Write in xml file

Publié le par damcuvelier

 

Public Const XML_FILE     = "xmlconfigfile.xml"
Public Const NODE_BIT     = "/Config/Bitlocker"

'--------------------------------------------------------------------
' Function Name - ReadXML()
'--------------------------------------------------------------------
Function ReadXML()
Dim xmlDoc,oNode
Set xmlDoc = CreateObject("Microsoft.XMLDOM")
    xmlDoc.Async = "false"
        If (xmlDoc.Load(XML_FILE)) Then
        '--Bitlocker--
        Set oNode = xmlDoc.DocumentElement.selectSingleNode(NODE_BIT & "/EnableBitlocker")
            If oNode.text = "True" then
            oEnableBitlocker = True  
            end if
        End If
    Set oNode = Nothing
    Set xmlDoc = Nothing       
end function

'--------------------------------------------------------------------
' Function Name - WriteXML()
'--------------------------------------------------------------------
Function WriteXML()
Dim xmlDoc
Dim oNode
Set xmlDoc = CreateObject("Microsoft.XMLDOM")
    xmlDoc.Async = "false"
        If (xmlDoc.Load(XML_FILE)) Then
        '--Bitlocker--
        Set oNode = xmlDoc.DocumentElement.selectSingleNode(NODE_BIT & "/EnableBitlocker")
            if oEnableBitlocker = True then
            oNode.text = "True"
            else
            oNode.text = "False"
            end if
        xmlDoc.save(XML_FILE)
        End If
    Set oNode = Nothing
    Set xmlDoc = Nothing       
end function               

Commenter cet article