Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am successfully parse an xml file with this code.
The code is returning all value for the normal tags, but not for the lists.
IE: I get all the value for 1,2,3 & 5 but never for 4
Hope this is clear enough

Public Function GetNodeValue(ByRef Nodes As MSXML2.IXMLDOMNodeList) As String
Dim xNode As MSXML2.IXMLDOMNode
For Each xNode In Nodes
If xNode.nodeType = NODE_TEXT Then
GetNodeValue = xNode.parentNode.nodeName & ":" & xNode.nodeValue
Select Case xNode.parentNode.nodeName
Case "1"
Debug.Print xNode.nodeValue
Case "2"
Debug.Print xNode.nodeValue
Case "3"
Debug.Print xNode.nodeValue
Case Else
'This line never returns a value
Debug.Print xNode.nodeValue
End Select
End If
If xNode.hasChildNodes Then
GetNodeValue xNode.childNodes
End If
Next
Set xNode = Nothing
End Function


Here is an example of the XML:
 <domain:STUFF>
<1>00000000000017</1>
<2>000</2>
<3>Hmmmmm</3>
<4>
<domain:flag sysid="2"/>
</4>
<5>1.000</5>
</domain:STUFF>
<domain:STUFF>
<1>00000000000020</1>
<2>000</2>
<3>BOB2</3>
<4>
<domain:flag sysid="2"/>
<domain:flag sysid="4"/>
<domain:flag sysid="5"/>
<domain:flag sysid="6"/>
<domain:flag sysid="7"/>
<domain:flag sysid="8"/>
</4>
<5>1.000</5>
</domain:STUFF>
Posted

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900