Visual Basic 6.0 Code - Reading XML 
Author Message
 Visual Basic 6.0 Code - Reading XML

Hi there, I'm trying out the following code in order to read in an XML
document.

Private Sub GetXML_Click()
    Dim objDOMDocument As MSXML.DOMDocument
    Dim root As IXMLDOMElement

    Set objDOMDocument = New DOMDocument
    objDOMDocument.async = False
    objDOMDocument.Load "c:\temp\5000017.XML"
    Set root = objDOMDocument.documentElement

    For Each child In root.childnodes
       MsgBox child.Text
    Next
End Sub

...but, I'm getting a compile error on the first line, indicating that
it can't find the library.  I'm sure it's something obvious, but I'm
not sure exactly where to go next.  Can anyone offer some assistance??

Once I've gotten the XML loaded, I also need to parse the nodes and
find a specific id/name within the document.  Any suggestions on how
to best achieve this????

Mucho Gracias!!!

Dan



Tue, 13 Dec 2005 20:32:02 GMT  
 Visual Basic 6.0 Code - Reading XML
1/ Have you added a refererence to the Microsoft MSXML component (and has it
been installed on your machine)?
2/ Are you using the latest version (MSXML 4) if so use MSXML2.DOMDocument40
3/ best way on msxml is using

set theNode = objDOMDocument.selectSingleNode(strXpath)
for one (first matching) node
or
set theNodeSet = objDOMDocument.selectNodes(strXpath)
 selectNodes for a node set (multiple matches)

strXPath is an Xpath expression describing the path to the node to be
selected

e.g.


If the ID is defined as a dataitem of type ID (in a DTD) then you can use
the xpath id function

"id('F1')"

Colin


Quote:
> Hi there, I'm trying out the following code in order to read in an XML
> document.

> Private Sub GetXML_Click()
>     Dim objDOMDocument As MSXML.DOMDocument
>     Dim root As IXMLDOMElement

>     Set objDOMDocument = New DOMDocument
>     objDOMDocument.async = False
>     objDOMDocument.Load "c:\temp\5000017.XML"
>     Set root = objDOMDocument.documentElement

>     For Each child In root.childnodes
>        MsgBox child.Text
>     Next
> End Sub

> ...but, I'm getting a compile error on the first line, indicating that
> it can't find the library.  I'm sure it's something obvious, but I'm
> not sure exactly where to go next.  Can anyone offer some assistance??

> Once I've gotten the XML loaded, I also need to parse the nodes and
> find a specific id/name within the document.  Any suggestions on how
> to best achieve this????

> Mucho Gracias!!!

> Dan



Tue, 13 Dec 2005 20:50:11 GMT  
 Visual Basic 6.0 Code - Reading XML

Quote:
> set theNode = objDOMDocument.selectSingleNode(strXpath)
> for one (first matching) node
> or
> set theNodeSet = objDOMDocument.selectNodes(strXpath)
>  selectNodes for a node set (multiple matches)

dont forget

objDOMDocument.setProperty "SelectionLanguage", "XPath"

to use XPath instead of MS pattern language



Tue, 13 Dec 2005 22:21:11 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. ANN: XML Support Added To Code Reports For Visual Basic

2. ANN: XML Support Added To Code Reports For Visual Basic

3. ANN: XML Support Added To Code Reports For Visual Basic

4. Read a FormDropDown in word 2000 from Visual Basic 6.0

5. do Visual Basic 6.0 and Visual Basic .NET version beta Working Both

6. Visual Basic 3.0 to Visual Basic 6.0

7. Preparing Your Visual Basic 6.0 Applications for the Upgrade to Visual Basic.NET

8. ANN: MS Code Advisor for Visual Basic (6.0 to .NET)

9. Code Analyser Add-In for Visual Basic 6.0 - evaluation copy

10. Code Analyser Add-In for Visual Basic 6.0 -- Evaluation copy available

11. Code Analyser Add-In for Visual Basic 6.0 - Evaluation copy

 

 
Powered by phpBB® Forum Software