Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

VBScript Query XML at multiple levels.

Posted on 2014-03-06
1
192 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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

828 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