Mega Code Archive

 
Categories / VB.Net / XML LINQ
 

Use LINQ to get the tasks for each employee and order them by the employees name

Imports System Imports System.Xml.Linq Imports System.Xml.XPath     Public Class MainClass         Public Shared Sub Main()             Dim employees As XElement = XElement.Load("EmployeesAndTasks.xml")             Dim linqQuery = From task In employees.<Employee>...<Task> _                             Select EmployeeName = task.Parent.Parent.<Name>.Value, _                                    TaskName = task.<Name>.Value, _                                    task.<Description>.Value _                             Order By EmployeeName         End Sub     End Class