Build a query to join the two XML trees on the employee's Id.
Imports System
Imports System.Xml.Linq
Public Class MainClass
Public Shared Sub Main()
Dim employees As XElement = XElement.Load("Employees.xml")
Dim titles As XElement = XElement.Load("Titles.xml")
Dim query = From emp In employees.<Employee> _
Group Join title In titles.<Title> _
On emp.@id Equals title.@empId _
Into TitleList = Group _
Select EmployeeName = emp.<Name>.Value, _
TitleList
For Each emp In query
Console.WriteLine(emp.EmployeeName)
For Each title In emp.TitleList
Console.WriteLine("{0} - {1}", title.<Name>.Value, title.<Status>.Value)
Next
Next
End Sub
End Class
Related examples in the same category