Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15621

Read XML file and insert into ListBox

$
0
0
Hello,

I'm trying to read an xml file and then put it in a ListBox in VB.net.
I just need the "Country" and "Name" columns.
But I only manage to read the entire XML file.

Does anyone have a tip on how I can read these 2 columns and get them into the ListBox?

Thanks in advance!



The XML file:

<Wines>
<Wine Name="Canapi Grillo" Country="Italie" Region="Sicilie" Soort="Wit" Druif="Grillo" AlcoholPrct="12"/>
<Wine Name="Miopasso Fiano" Country="Italie" Region="Sicilie" Soort="Wit" Druif="Fiano" AlcoholPrct="13"/>
<Wine Name="Elegance Sauvignon Blanc" Country= "Frankrijk" Region="Pays d'Oc" Soort="Wit" Druif="Sauvignon Blanc" AlcoholPrct="11,5"/>
</Wines>



The code:

Code:

Private Sub WijnLijstBarButton_Click(sender As Object, e As RoutedEventArgs)
Dim xdocument As XDocument = XDocument.Load("..\..\wine.xml")
Dim wines As IEnumerable(Of XElement) = xdocument.Elements()
For Each wine In wine
      Listbox1.Items.Add(wine)
Next wine


Viewing all articles
Browse latest Browse all 15621

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>