Query elements by attribute value
Imports System Imports System.Reflection Imports System.Xml Module Module1 Sub Main() Dim xml As XDocument = XDocument.Load("People.xml") Dim query = From p In xml.Elements("people").Elements("person") _ Where p.Element("id").Value = 1 _ Select p For Each record In query Console.WriteLine("Person: {0} {1}", _ record.Element("firstname").Value, _ record.Element("lastname").Value) Next End Sub End Module