Mega Code Archive

 
Categories / VB.Net / XML
 

XNode ElementsBeforeSelf returns a collection of the sibling elements before 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>Text content.                     <Child1>child1 content</Child1>                     <Child2>child2 content</Child2>                     <Child3>child3 content</Child3>More text content.                     <Child4>child4 content</Child4>                     <Child5>child5 content</Child5>                 </Root>         Dim child As XElement = xmlTree.<Child3>(0)         Dim elements As IEnumerable(Of XElement) = child.ElementsBeforeSelf()         For Each el In elements             Console.WriteLine(el.Name)         Next     End Sub End Class