UnderTheRadar
IS-IT--Management
Hi, I'm a little new to VBScript and I'm having some trouble traversing an xml file. I've done some C++ xml stuff a while back but I had a different parser. I'm not sure if this should be in the VBScript or XML forum, but here goes. Here's a piece of the xml file.
If you're familiar with login scripts, you can probably see what I'm trying to do here. Basically, I have a WSH file that hosts a vbscript that's running through the GPO's for users during logon. It retrieves the gateway ip address of the workstation and tries to find it in this xml file. If it finds it, I need to be able to retrieve basically all of the values for that particular gateway, drive mappings to local file shares, software distribution points, printers, virus updates, etc.
It's a very large WAN (55,000+ nodes) and everything is centrally managed (no local BDC's) so I need this to be an efficient process, hence the move to XML/VBScript with an administrative GUI, vs. the old DOS batch and CSV files we've been using.
So far, I'm able to retrieve the gateway and find it in the xml file with an xpath statement, but I'm having trouble traversing to previous and/or next relative nodes and retrieving those values. And I'm not so sure xpath is the way to go?
Here's that code:
Thanks for any help on this. I truly appreciate it.
Cheers,
UTR
Code:
<facility id="TEST"_FACID>
<unit>TEST_UNIT</unit>
<location>TEST_LOCATION</location>
<street>TEST_STREET</street>
<city>TEST_CITY</city>
<state>TEST_STATE</state>
<zip>TEST_ZIP</zip>
<gateway ip="192.168.1.1">
<navls>NAV_LOCALSERVER</navls>
<usdls>USD_LOCALSERVER</usdls>
<usdss count="0">
<name>USD_STAGINGSHARE1</name>
</usdss>
<usdss count="0">
<name>USD_STAGINGSHARE2</name>
</usdss>
<drive letter="S">
<server>FILE_SERVER</server>
<share>SHARE1$</share>
</drive>
<drive letter="T">
<server>FILE_SERVER</server>
<share>SHARE2$</share>
</drive>
<printer name="B/W PRINTER">
<server>PRINT_SERVER</server>
</printer>
<printer name="COLOR PRINTER">
<server>PRINT_SERVER</server>
</printer>
</gateway>
</facility>
If you're familiar with login scripts, you can probably see what I'm trying to do here. Basically, I have a WSH file that hosts a vbscript that's running through the GPO's for users during logon. It retrieves the gateway ip address of the workstation and tries to find it in this xml file. If it finds it, I need to be able to retrieve basically all of the values for that particular gateway, drive mappings to local file shares, software distribution points, printers, virus updates, etc.
It's a very large WAN (55,000+ nodes) and everything is centrally managed (no local BDC's) so I need this to be an efficient process, hence the move to XML/VBScript with an administrative GUI, vs. the old DOS batch and CSV files we've been using.
So far, I'm able to retrieve the gateway and find it in the xml file with an xpath statement, but I'm having trouble traversing to previous and/or next relative nodes and retrieving those values. And I'm not so sure xpath is the way to go?
Here's that code:
Code:
Dim strFacid, strUnit, strLocation, strStreet, strCity, strState, strUsd, strNav
Set xml = CreateObject("MSXML2.DOMDocument")
xml.async = False
xml.setProperty "SelectionLanguage", "XPath"
xml.load("\\server\netlogon\gateways.xml")
Set xpath = xml.selectNodes("//@ip")
xpath.context = xml
buf = ""
bContinue = True
Do While (bContinue)
Set node = Nothing
Set node = xpath.NextNode()
If Not (node Is Nothing) Then
If node.Text = strDefaultIPGateway Then
bContinue = False
bGWFound = True
buf = buf & node.Text
objIntExplorer.Document.WriteLn ("<font size=""2"";
color=""#33CC33""><b>Gateway IP Address " & buf & ";
Located in Facility ID Table.</b></font><br><br>"
Exit Do
End If
Else
bContinue = False
Dim err_NoGateway
objIntExplorer.Document.WriteLn ("<font size=""2"";
color=""red""><b>Unable to locate Default Gateway IP Address ";
& strDefaultIPGateway & " in Facilitiy ID;
Table.</b></font><br><br>")
End If
Loop
Thanks for any help on this. I truly appreciate it.
Cheers,
UTR