VBScript Query XML at multiple levels.

Blowfelt82
Blowfelt82 used Ask the Experts™
on
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?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Senior Systems and Integration Developer
Commented:
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.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial