Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old July 18th, 2005, 09:43 AM
Devinfox Devinfox is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Posts: 1 Devinfox User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 m 7 sec
Reputation Power: 0
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.

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > VBscript help please :)


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT