|
-
Jan 5th, 2011, 01:59 PM
#1
Thread Starter
New Member
Looping through XML
I have the following XML file:
<DirSpace>
<Servers>
<SvrName>SERVER01</SvrName>
<dirName>"C:\dir1\"</dirName>
<PathFileName>"C:\test1"</PathFileName>
</Servers>
<Servers>
<SvrName>SERVER02</SvrName>
<dirName>"C:\dir2\"</dirName>
<PathFileName>"C:\test2"</PathFileName>
</Servers>
<Servers>
<SvrName>SERVER03</SvrName>
<dirName>"C:\dir3\"</dirName>
<PathFileName>"C:\test3"</PathFileName>
</Servers>
</DirSpace>
I am using the following code:
Set objXMLDoc = CreateObject("Microsoft.XMLDOM")
objXMLDoc.async = False
objXMLDoc.load("test.xml")
Dim root, i
Set strNode = objXMLDoc.SelectNodes("//Servers")
Set root = objXMLDoc.documentElement
msgbox "No. of child nodes: "& root.childNodes.length
Set objChildNodes = objXMLDoc.documentElement.childNodes
For i = 0 To (root.childNodes.length)-1
msgbox(root.childNodes.item(i).text)
Set NodeList = Root.getElementsByTagName("SvrName")
Next
WHAT I really need to do is be able to loop through and do something like the following for a report :
Server1 is using 32 GB in "C:\dir1\" and the path is "C:\test1\" has 3 files in it
Server2 is using 32 GB in "C:\dir2\" and the path is "C:\test2\" has 3 files in it
Server3 is using 32 GB in "C:\dir3\" and the path is "C:\test3\" has 3 files in it
SO I need it to go to the first <SERVER></SERVER> and do something with that info and then go to the next set and so on and so forth. I need to be able to use variable names for like <SVRNAME></SVRNAME> so that I can have other things done based on that info.
If you have any questions feel free to email me. 
Steve
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|