Extensions.Ancestors(T) returns a collection of elements that contains the ancestors of every node
Imports System
Imports System.Xml
Imports System.Xml.XPath
Public Class MainClass
Public Shared Sub Main()
Dim xmlTree As XElement = _
<Root>
<Child1>
<GrandChild1>
<GreatGrandChild1>content</GreatGrandChild1>
</GrandChild1>
</Child1>
<Child2>
<GrandChild2>
<GreatGrandChild2>content</GreatGrandChild2>
</GrandChild2>
</Child2>
</Root>
Dim greatGrandChildren = From el In xmlTree.Descendants _
Where el.Name.LocalName.StartsWith("Great") _
Select el
For Each de As XElement In greatGrandChildren
Console.WriteLine(de.Name)
Next
End Sub
End Class