Imports System.Collections.Generic
Class Car
Public PetName As String
Public ID As Integer
End Class
Module Program
Sub Main()
Dim data As New List(Of Car)
data.Add(New Car With {.PetName = "A", .ID = 10})
data.Add(New Car With {.PetName = "Pat", .ID = 11})
data.Add(New Car With {.PetName = "Danny", .ID = 12})
data.Add(New Car With {.PetName = "B", .ID = 13})
Dim vehicles As XElement = _
<Inventory>
<%= From c In data _
Select <Car ID=<%= c.ID %>>
<PetName><%= c.PetName %></PetName>
</Car> %>
</Inventory>
Console.WriteLine(vehicles)
End Sub
End Module
|