First it is necessary to know the following to answer your question:
- If you have already done the XML file interpreter and,
- How you’re handling each element.
Assuming you are using a dynamic class, that there are properties Nome
and Path
, list the XML elements with a ghost list, adding each name to the list.
Below is a pseudo-code, whose done for you understand the algorithm.
Variável ListaFantasma é uma nova Lista (de string)
Sendo XmlElement cada elemento XML no arquivo, faça:
Se ListaFantasma contém XmlElement -> Nome:
// Contém o nome, o que fazer agora?
Caso contrário:
// Não contém o nome
Fim do Se
Fim do Sendo
The above pseudo-code in Visual Basic . NET would look something like this:
Public Class MusicaItem
Public Property Nome As String
Public Property Path As String
End Class
...
Dim Musicas As New List(Of MusicaItem)
Dim ListaFantasma As New List(Of String)
For Each Musica As MusicaItem In Musicas
If ListaFantasma.Contains(Musica.Nome) Then
' Contém o nome
Else
' Não contém o nome
...
' Sempre adicione o nome para saber que ele já passou por aqui
ListaFantasma.Add(Musica.Nome)
End If
Next
In the above code, I have already created the dynamic class for each element in your XML. The item Musica.Nome
is added to the ghost list, so it is always checked if the item already exists in the list.
If you haven’t developed code to interpret XML, consider opening a new question, or learn how to read XML files with Visual Basic.