Link to home
Start Free TrialLog in
Avatar of Mike Caldwell
Mike CaldwellFlag for United States of America

asked on

How to parse an XML file with VB Scritp?

I can generate an XML file, as attached.  I have given up on trying to do anything with the data stream as received, and instead am saving it to a .TXT file, which I need to open and then pull out the stuff I want with VB Script.  In the attached file, I need to capture the value of the APNMB field, then the date associated with each FWDAY field.  So output should look like this in the target file:

Application:  12345678
Date:  2011-05-06
Date:  2011-10-06
.
.
the rest of the date (FWDAY) fields until the end of the list.  I have found a few parsers on line, but they seem to be accessing a web site not a file; I didn't understand them anyway!
3D.txt
ASKER CERTIFIED SOLUTION
Avatar of plusone3055
plusone3055
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mike Caldwell

ASKER

Great help 3055.  This works fine:

Set xmlDoc = _
  CreateObject("Microsoft.XMLDOM")

xmlDoc.Async = "False"
xmlDoc.Load("3D.txt")

Set colNodes=xmlDoc.selectNodes _
  ("//APNMB")

For Each objNode in colNodes
msgbox "Application: " & objnode.text
Next

Open in new window


 I can pull out APNMB or FWTYP, but having trouble still in two ways:  listing out the dates under one APNMB, then the FWTYPs under the next APNMB.
Correction: there should be a list of FWTYPs under each individual APNMB.
Didn't get me all the way; I need to know how to deal with child nodes and their child nodes, but learned a lot and a good start.  I'm probably going to give up using VB Script for this.