XNode.ElementsAfterSelf Method (XName)
Returns a filtered collection of the sibling elements after this node, in document order. Only elements that have a matching XName are included in the collection.
Assembly: System.Xml.Linq (in System.Xml.Linq.dll)
This method only includes siblings in the returned collection. It does not include descendants.
This method uses deferred execution.
The following example creates an element with some complex content. It then uses this method to retrieve the sibling elements, in document order.
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.ElementsAfterSelf("Child4") For Each el In elements Console.WriteLine(el.Name) Next
This example produces the following output:
Available since 4.5
Available since 3.5
Portable Class Library
Supported in: portable .NET platforms
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Available since 8.1