codice:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim xmlDoc As New XmlDocument()
xmlDoc.Load(Server.MapPath("nodi.xml"))
Dim radice As XmlElement = xmlDoc.DocumentElement()
Dim nodi As XmlNodeList = Nothing
Dim nodo As XmlNode = Nothing
Dim lt As New List(Of String)
nodo = radice.SelectSingleNode("/DocumentElement/Nodi")
ElaboraNodi(nodo, lt, -1)
For Each s As String In lt
Me.ListBox1.Items.Add(New ListItem(s))
Next
End Sub
Protected Sub ElaboraNodi(ByVal nodo As XmlNode, ByVal lt As List(Of String), ByVal indice As Integer)
Dim nodi As XmlNodeList = nodo.SelectNodes("./Nodo")
If indice = -1 Then
For i As Integer = 0 To nodi.Count - 1
nodo = nodi(i)
Dim value = nodo.Attributes("Nome").Value
lt.Add("/" & value)
ElaboraNodi(nodo, lt, lt.Count - 1)
Next
Else
For i As Integer = 0 To nodi.Count - 1
nodo = nodi(i)
Dim value = nodo.Attributes("Nome").Value
lt.Add(lt(indice) & "/" & value)
ElaboraNodi(nodo, lt, lt.Count - 1)
Next
End If
End Sub