reading xml file with vbscript

前端 未结 2 1621
眼角桃花
眼角桃花 2020-12-18 04:09

I am trying to write a vbscript to automate the configuration of a storage array. I\'m having some difficulty figuring out how best to navigate the XML.

An example s

相关标签:
2条回答
  • 2020-12-18 04:50

    This works for me:

    sub main
        Set nodeList = xmlDoc.documentElement.selectNodes("//interface")
    
        For Each node in nodeList
            handleNode(node)
        Next
    end sub
    
    sub handleNode(node)
        Dim port, ipaddress, netmask, attribute
    
        For each elem in node.childNodes
            Select Case node.tagName
                Case "port"
                    port = elem.text
                Case "ipaddress"
                    ipaddress = elem.text
                Case "netmask"
                    netmask = elem.text
                Case "tag with attributes"
                    attribute = elem.getAttribute("attributeName")
            End Select
        Next
    
        WScript.Echo "Port " & port & " has IP address of " & ipaddress & " and useful attribute " & attribute
    
    end sub
    
    0 讨论(0)
  • 2020-12-18 05:10

    First approach:

    For Each Elem In NodeList 
       SET port = Elem.getElementsByTagName("Port")(0)
       SET ip = Elem.getElementsByTagName("IPADDRESS")(0)
       WScript.Echo "Port " & port.nodeValue & " has IP address is " & ip.nodeValue
    Next
    
    0 讨论(0)
提交回复
热议问题