Mega Code Archive

 
Categories / VB.Net / XML
 

XNode Ancestors returns a collection of the ancestor elements of this node

Imports System Imports System.Xml Imports System.Xml.Schema Imports System.Linq Imports System.Collections Imports System.Collections.Generic Class MainClass     Shared Sub Main()         Dim xmlTree As XElement = _                 <Root>                     <Child>                         <GrandChild>content</GrandChild>                     </Child>                 </Root>         Dim grandChild As IEnumerable(Of XElement) = xmlTree...<GrandChild>         For Each el In grandChild.Ancestors()             Console.WriteLine(el.Name)         Next     End Sub End Class