|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
VBscript help please :)
First, let me tell you what im trying to do with vbscript before i give you my problem.
Im trying to write a script that will read an XML file(a group policy object report) it will pick out all of the names, and states of every single GPO in the file. Then take that data and put it into an excel spreadsheet. im using xmldoc.getElementsByTagName in order to pick the data out of the html tags. The data i need is pretty simple. i need to pull out all of the information from 6 xml tags. <q1:Name>, <q2:Name>, <q4:Name>, <q1:state> <q2:type>, and <q4:state> Pulling the data is the easy part, the problem is that when i pull this info and put it into an excel file, it all becomes out of order because some group policy objects in the xml file do not have states. this makes the code grab the state of the next GPO and from there its all downhill. here is my code to aquire all of the data i need. 'this section loads the xml file Set xmldoc = CreateObject("Microsoft.XMLDOM") xmlDoc.async="false" File = xmlDoc.load(strname) 'this if-then statement begins error checking by closing the program if the xml file does not load. 'if the file loads, it then begins the main program function. If file Then WScript.Echo "Xml loaded succesfully" 'this section aquires all of the data needed from the xml file set objList = xmldoc.getElementsByTagName("*") set objList1 = xmldoc.getElementsByTagName("q1:Name") set objList2 = xmldoc.getElementsByTagName("q2:Name") set objList3 = xmldoc.getElementsByTagName("q4:Name") set objList4 = xmldoc.getElementsByTagName("q1:State") set objList5 = xmldoc.getElementsByTagName("q2:Type") set objList6 = xmldoc.getElementsByTagName("q4:State") for testing purposes, im writing the info to a text file.. here is the code ' this section is a series of loops that list all of the aquired data for counter = 1 to (objlist1.length) filedata = objlist1(counter).text writefile.WriteLine ("Q1 GPO ") & (counter) & (" ") & filedata next writefile.writeline vbcrlf 'here is another snippet of code that writes a state to a text file for counter = 1 to (objlist4.length) filedata = objlist4(counter).text writefile.WriteLine ("Q1 State ") & (counter) & (" ") & filedata next writefile.writeline vbcrlf Can anyone help me by giving me a direction to research? i would GREATLY appreciate the help. i need to find a way for it to creat a null value for q1:state if it does not find anything associated with a group policy in order to keep the data organized right. |
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > VBscript help please :) |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|