I created a program that generates a XML
equal to:
<Pastas3>
<Grupos pasta="C:\...\Arquivos\Videos">
<Video>C:\...\Arquivo 1</Video>
<Video>C:\...\Arquivo 2</Video>
<Video>C:\...\Arquivo 3</Video>
<Video>C:\...\Arquivo 4</Video>
<Grupos pasta="C:\...\Arquivos\Videos\Videos">
<Video>C:\...\Arquivo 1</Video>
<Video>C:\...\Arquivo 2</Video>
<Video>C:\...\Arquivo 3</Video>
<Video>C:\...\Arquivo 4</Video>
<Grupos pasta="C:\...\Arquivos\Videos\Videos\Video1">
<Video>C:\...\Arquivo 1</Video>
<Video>C:\...\Arquivo 2</Video>
<Video>C:\...\Arquivo 3</Video>
<Video>C:\...\Arquivo 4</Video>
</Grupos>
<Grupos pasta="C:\...\Arquivos\Videos\Video\Video 2">
<Video>C:\...\Arquivo 1</Video>
<Video>C:\...\Arquivo 2</Video>
<Video>C:\...\Arquivo 3</Video>
<Video>C:\...\Arquivo 4</Video>
<Grupos pasta="C:\...\Arquivos\Videos\Video\Video 2\Algo">
<Video>C:\...\Arquivo 1</Video>
<Video>C:\...\Arquivo 2</Video>
<Video>C:\...\Arquivo 3</Video>
<Video>C:\...\Arquivo 4</Video>
</Grupos>
</Grupos>
</Grupos>
<Grupos pasta="C:\...\Arquivos\Videos">
<Video>C:\...\Arquivo 1</Video>
<Video>C:\...\Arquivo 2</Video>
<Video>C:\...\Arquivo 3</Video>
<Video>C:\...\Arquivo 4</Video>
</Grupos>
</Grupos>
</Pastas3>
The problem is that I need to get the <Grupos pasta=
and <Video> ... </Video>
values from a given group and read all subsequent <Grupos pasta=
and <Video> ... </Video>
. I've been looking for some time on the Internet some way to do this and the ones I found read all the content. I found some other ways too, but that I could not implement. The best code I could do was this, but it only reads the first group last:
Private Sub ColocarList()
Dim xd As XmlDocument = New XmlDocument
xd.Load("C:\Users\lourd\source\repos\Teste_Na a\Teste_Na a\xml.xml")
Dim n As XmlNode = xd.DocumentElement()
DaCerto(n)
End Sub
Private Sub DaCerto(z As XmlNode)
Dim gp As New ListViewGroup
For Each node As XmlNode In z
If node.Attributes.GetNamedItem("pasta").InnerText <> Nothing Then
gp = New ListViewGroup(node.Attributes.GetNamedItem("pasta").InnerText) With {
.Name = node.Attributes.GetNamedItem("pasta").InnerText
}
ListView1.Groups.Add(gp)
For i = 0 To node.ChildNodes.Count - 1
If node.ChildNodes(i).Name = "Video" Then
ColocarPastasDestroDoListView(node.ChildNodes(i).InnerText, gp)
ElseIf node.ChildNodes(i).Name = "Grupo" Then
DaCerto(node.ChildNodes(i))
End If
Next
End If
Next
End Sub
So can anyone help me with how do I do this?
Edit:
When I select the folder Filmes
it creates groups with the name of the folders and the content of them goes into the group in ListView
.
NowwhenIselecttheteste
folderitselectswhat'sinsideit.
WhatIwouldliketocreateisonly1xmlper"root node" of TreeView
. For example it has 2 "root knots" called Movies in the Tree.