VB Script Parsing XML Attributes - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

VB Script Parsing XML Attributes

bhaskarvphanibhaskarvphani Posts: 3Member

I am trying to develop a script which can parse all nodes/elements and its attributes of an XML.

I am able to read all nodes/elements but not attributes of it like

Can you please help me to going in parse all elements/attributes of XML given below


<?xml version="1.0"?>


2011Nature Publishing Group, a division of Macmillan Publishers Limited. All Rights Reserved.


Biology Algal synchronized swimming

Suspensions of swimming algal cells form intricate mottled patterns that are governed by a complex interplay between light, gravity and fluid dynamics. The patterns (pictured) change with shifting lighting conditions, which could one day be exploited to improve the yields of bioreactors that use algae to produce biofuel.

Rosie Williams and Martin Alan Bees of the University of Glasgow, UK, studied the patterns formed by suspensions of Chlamydomonas augustae cells in response to changes in the orientation and intensity of the light source. As overhead white light grew brighter, dense groups of cells first moved apart, then drew closer together. When the algae were lit from below, brighter light resulted in a shortening and then a levelling off of distances between dense cell groups.

Such pattern changes could be exploited to increase the penetration of light and nutrients to cell suspensions, and to concentrate cells for harvesting.

J. Exp. Biol. 24, 2398–2408 (2011) 10.1242/jeb.051094


My VB script Code:

Dim goFS
Set goFS = CreateObject( "Scripting.FileSystemObject" )
Dim sDir
sDir = "C:work"
Dim oXDoc
Set oXDoc = CreateObject( "Msxml2.DOMDocument" )
oXDoc.async = False
Dim oFile
For Each oFile In goFS.GetFolder( sDir ).Files
WScript.Echo "looking at", oFile.Name
WScript.Echo "will load", oFile.Path
If oXDoc.load( oFile.Path ) Then
WScript.Echo "successfully loaded", oFile.Name
End If
Set ndlEventId = oXDoc.documentElement.selectNodes("//*")
for i = 0 to ndlEventId.length-1
WScript.Echo ndlEventId(i).nodeName & " :: " &ndlEventId(i).text
If ndlEventId(i).text="" Then
WScript.Echo s
Set attrvalue=oXDoc.getAttribute(s)
WScript.Echo attrvalue
End if

Thanks in advance

Sign In or Register to comment.