Van een programma dat ik ooit eens snel geschreven heb om msn conversaties te herbekijken -- 'k weet wel niet meer hoe het juist ineen zat en 't was serieus bricoleerwerk, maar misschien heb je er iets aan:
(form1 heeft enkel richtextbox1)
Public Sub xxx()
Dim yNL As Xml.XmlNodeList, yO As Xml.XmlNode, zO As Xml.XmlNode, tN As TreeNode, aO As Xml.XmlNode
Dim yXML As New Xml.XmlDocument, yATC As Xml.XmlAttributeCollection, yAT As Xml.XmlAttribute, aN As TreeNode, bO As Xml.XmlNode
yXML.Load("Path2file.xml")
If yXML.HasChildNodes = False Then Exit Sub
yNL = yXML.ChildNodes
For Each yO In yNL
tN = TreeView2.Nodes.Add(yO.LocalName)
If yO.HasChildNodes = True Then
For Each zO In yO.ChildNodes
tN.Nodes.Add(zO.OuterXml)
If zO.HasChildNodes = True Then
For Each aO In zO.ChildNodes
' From To Text
aN = tN.Nodes.Add(aO.LocalName)
If aO.HasChildNodes = True Then
'User User #Text
For Each bO In aO.ChildNodes
yATC = bO.Attributes
aN.Nodes.Add(bO.Name)
If (yATC Is Nothing) = False Then
For Each yAT In yATC
aN.Nodes.Add(yAT.Value)
Next
End If
Next
End If
Next
End If
Next
End If
Next
End Sub
Public Sub display_Conversations()
Dim nCONV As TreeNode, nF As String, nT As String
Dim SESSIONID As Integer = 0, aCONV As Integer = 0
Dim tCONV As TreeNode, rtf As RichTextBox = RichTextBox1, rtf_FONT As Font = rtf.Font
On Error Resume Next
Dim zXML As New Xml.XmlDocument, zLOG As Xml.XmlNodeList, zM As Xml.XmlNode
zXML.Load("path2file.xml")
If zXML.HasChildNodes = False Then Exit Sub
zLOG = zXML.ChildNodes(2).ChildNodes 'every childnode is a messageline
For Each zM In zLOG
'Get SessionID
SESSIONID = zM.Attributes("SessionID").Value
If SESSIONID <> aCONV Then
'tCONV = TreeView2.Nodes.Add("CONVERSATION " & SESSIONID & " -- " & zM.Attributes("DateTime").Value)
rtf.Text &= vbCrLf & vbCrLf & "----- CONVERSATION " & SESSIONID & " -- " & zM.Attributes("DateTime").Value.ToString & vbCrLf
aCONV = SESSIONID
End If
'Get the "From"
nF = zM.ChildNodes(0).ChildNodes(0).Attributes("FriendlyName").Value.ToString
rtf.Text &= vbCrLf & "::" & nF & "::" & vbCrLf
'Get the "Text"
nT = zM.ChildNodes(2).InnerText
'tCONV.Nodes.Add(nF & " :: " & nT)
rtf.Text &= nT & vbCrLf
Next
End Sub
EDIT :: form1 heeft blijkbaar ook een TreeView2, dus ik vermoed dat ik alles eerst naar een TreeView heb omgezet en dan in die RichTextBox1 heb gedumpt