2
I created a program that generates a XML
as is:
<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 I need to get the figures <Grupos pasta=
and <Video> ... </Video>
from a particular group and read all the <Grupos pasta=
and <Video> ... </Video>
subsequent. I’ve been looking for some way to do this on the Internet and the ones I found read all the content. I found some other ways too, but I couldn’t implement them. The best code I could do was this, but it only reads the first group past:
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
Then someone can help me with how I do it?
Edit:
When I select the folder Filmes
it creates groups with the name of the folders and their content goes into the group in the ListView
.
Now when I select the folder teste
he selects what’s inside her.
What I would like is to create only 1 xml by "root node" of TreeView
. For example has 2 "root node" called Movies in Tree.
I don’t think your XML is well structured...
Grupos
insideGrupos
? Shouldn’t have aSubGrupo
within aGrupo
?– João Martins
I never used XML and kind of put the cart in front of the donkeys. The xml I need has basically 2 information the
Atributo
groups and the value inVideo
. So I’ll need to create a name for each group?– Lucas Pedro