OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
RE: [xml-dev] need help / insight on parsing some xml with vb6

Hi Tom, 


In VB6 you have the XML DOM objects. Include a reference to “Microsoft XML v4.0” in your project to use it.


There are three basic operations you’ll need to get data out from the XML document:


1.       Create an XML Document object


  Dim objXML As New MSXML2.DOMDocument


2.       Load your XML document into the object, passing its location on disk or URL


objXML.Async = false

objXML.Load( “c:\users\BillGates\Documents\competition.xml” )



3.       Select the nodes you want to use with XPath and the method SelectNodes


Dim NodeList as XMLDOMNodeList

Set NodeList = objXML.SelectNodes( “/ArrayOfCompetition/Competition/EventName” )


(Note to readers using better programming languages: Did you notice that there is no need to bother with namespace handling? Oh! Those old good times :D ).


This will give you a collection of all the EventName elements in every Competition element in your document.


The you can loop every resulting node with a For .. in … do  loop in VB, like this:


   Dim xNode As MSXML.IXMLDOMNode

   For Each xNode In NodeList

                Print xNode.text


Is a good idea to add error handling. Take a look to this article from Microsoft to learn how to deal with XML, including error handling: http://msdn.microsoft.com/en-us/library/aa468547.aspx


The key to be proficient with XML is XPath. Somebody else can recommend you a “Good” resource for learning it (Sorry me not… I learned XPath in w3schools :D ).


Hope this helps,


-          Bill


De: Tom Martin [mailto:tomdmartin@gmail.com]
Enviado el: viernes, 13 de junio de 2014 1:06 p. m.
Para: xml-dev@lists.xml.org
Asunto: [xml-dev] need help / insight on parsing some xml with vb6



I'm working on a project and need to parse some xml code using vb6.


The xml file as around 50 "sections" in it that I need to examine and pull out certain info...

  <?xml version="1.0" encoding="utf-8" ?>

- <Competition>

  <ChiefJudge />


  <CompetitionName />


  <EventName>Southwest Corps Connection</EventName>



  <Location>Mesa AZ</Location>









What I need to do is parse all of this out into some combo boxes. Not sure where to start...


Thanks. Tom

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS