Solved

VBScript Query XML at multiple levels.

Posted on 2014-03-06
1
189 Views
Last Modified: 2014-04-04
I have XML in the following format...

<xml>
 <machine id="512">
  <type name="Windows" />
  <external>
   <type name="Linux" />
   <type name="Apple" />
  </external>
 </machine>
</xml>

Open in new window


This XML is loaded into an object named OSystem. I query this as follows...

Set Nodes = OSystem.SelectNodes("/machine[@id='512']/")
Set Items = Nodes.getElementsByTagName ("type")

Open in new window


This returns the Windows type element, I need a way to get all type elements at both the machine and machine/external level. So all 3 basically...

Preferably if this can be done in one statement, but if two are needed and then the sets could be joined than this could be an option?
0
Comment
Question by:Blowfelt82
1 Comment
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
ID: 39909416
Just change your initial select to:
Set Nodes = OSystem.SelectNodes("/machine[@id='512']//type")

Open in new window

That way you won't need the second line of your original code either.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Well hello again!  Glad to see you've made it this far without giving up.  In this, the fourth installment of my popular series, I'm going to cover functions and subroutines, what they are, and why they are useful.  Just in case you stumbled onto th…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question