Solved

VBScript Query XML at multiple levels.

Posted on 2014-03-06
1
186 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
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

772 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now