Ok, Im new to LINQ to XML and need some help getting my query set up. I have googled for hours and it seems every diffrent website has a diffrent way of doing it and I am getting really really confused. Here is my XML:
Now, I have sucessfully got my document loaded into VB:
I would like the output from my query to be:
0001 Jack Loper
0002 Joe Bloggs
How would I set up my query? At the moment I have this, but I have no idea what the hell I am actually doing:
If you could explain each step, that would be nice and helpful :) . Thanks
Code:
<?xml version = "1.0"?>
<booking>
<client>
<id>0001</id>
<name>Jack Loper</name>
<numofseats>3</numofseats>
<seats>C1C2C3</seats>
<cost>30</cost>
</client>
<client>
<id>0002</id>
<name>Joe Bloggs</name>
<numofseats>1</numofseats>
<seats>D8</seats>
<cost>10</cost>
</client>
</booking>
Code:
Dim BookingDatabase As XDocument
BookingDatabase = XDocument.Load(My.Application.Info.DirectoryPath & "\Booking_Database.xml")
0001 Jack Loper
0002 Joe Bloggs
How would I set up my query? At the moment I have this, but I have no idea what the hell I am actually doing:
Code:
Dim query = From ex In BookingDatabase.Descendants.Elements("client")
Select id = ex.Attribute("id").Value
For Each ex In query
Console.WriteLine(ex)
Next