Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Xml Problem 1

Status
Not open for further replies.

kennedymr2

Programmer
May 23, 2001
594
AU
I am trying to read the values of the field <VALUE RNR="1">0</VALUE> <VALUE RNR="2">555.5</VALUE> etc
I can get NR_VALUES but not sure of how to get the above into the listbox


<?xml version="1.0"?>
<MAIN>
<MN>
<NR_VALUES>18</NR_VALUES>
<VALUE RNR="1">111.0</VALUE>
<VALUE RNR="2">555.5</VALUE>
<VALUE RNR="3">11.5</VALUE>
</MN>
</MAIN>


Dim pDoc As MSXML2.DOMDocument
Dim i As Long
Set pDoc = New DOMDocument
pDoc.async = False
List1.Clear
Dim xyz As String
If pDoc.Load("c:\test\xml.xml") Then
For i = 0 To pDoc.selectNodes("//MN").length - 1
xyz = pDoc.selectNodes("//MN").Item(i).selectSingleNode("NR_VALUES").Text & ","
List1.AddItem xyz
Next i
End If


Really appreciate any help

Regards Kennedymr2
 
Something like this should get you started:

Code:
Private Sub Command1_Click()
    Dim objXML As New MSXML2.DOMDocument
    Dim objElem As MSXML2.IXMLDOMElement
    Dim objNode As MSXML2.IXMLDOMNode
    Dim objAttr As MSXML2.IXMLDOMAttribute
    List1.Clear
    If objXML.Load("C:\Test.xml") Then
        Set objElem = objXML.selectSingleNode("//MN")
        For Each objNode In objElem.childNodes
            For Each objAttr In objNode.Attributes
                List1.AddItem objAttr.Text & " = " & objNode.Text
            Next
        Next
    End If
End Sub

Swi
 
Swi..

Thanks for the help...all working fine now.


Regards Kennedymr2
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top