reading xml file with vbscript

好久不见. 提交于 2019-11-29 11:11:43

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

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
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!