Redigeeri

Jagamisviis:


XNode.ElementsAfterSelf Method

Definition

Returns a collection of the sibling elements after this node, in document order.

Overloads

ElementsAfterSelf()

Returns a collection of the sibling elements after this node, in document order.

ElementsAfterSelf(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.

Remarks

This method uses deferred execution.

ElementsAfterSelf()

Source:
XNode.cs
Source:
XNode.cs
Source:
XNode.cs

Returns a collection of the sibling elements after this node, in document order.

public:
 System::Collections::Generic::IEnumerable<System::Xml::Linq::XElement ^> ^ ElementsAfterSelf();
public System.Collections.Generic.IEnumerable<System.Xml.Linq.XElement> ElementsAfterSelf ();
member this.ElementsAfterSelf : unit -> seq<System.Xml.Linq.XElement>
Public Function ElementsAfterSelf () As IEnumerable(Of XElement)

Returns

An IEnumerable<T> of XElement of the sibling elements after this node, in document order.

Examples

The following example creates an element with some complex content. It then uses this method to retrieve the nodes in document order.

XElement xmlTree = new XElement("Root",  
    new XText("Text content."),  
    new XElement("Child1", "child1 content"),  
    new XElement("Child2", "child2 content"),  
    new XElement("Child3", "child3 content"),  
    new XText("More text content."),  
    new XElement("Child4", "child4 content"),  
    new XElement("Child5", "child5 content")  
);  
XElement child = xmlTree.Element("Child3");  
IEnumerable<XElement> elements = child.ElementsAfterSelf();  
foreach (XElement el in elements)  
    Console.WriteLine(el.Name);  
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()  
For Each el In elements  
    Console.WriteLine(el.Name)  
Next  

This example produces the following output:

Child4  
Child5  

Remarks

This method only includes siblings in the returned collection. It does not include descendants.

This method uses deferred execution.

See also

Applies to

ElementsAfterSelf(XName)

Source:
XNode.cs
Source:
XNode.cs
Source:
XNode.cs

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.

public:
 System::Collections::Generic::IEnumerable<System::Xml::Linq::XElement ^> ^ ElementsAfterSelf(System::Xml::Linq::XName ^ name);
public System.Collections.Generic.IEnumerable<System.Xml.Linq.XElement> ElementsAfterSelf (System.Xml.Linq.XName name);
public System.Collections.Generic.IEnumerable<System.Xml.Linq.XElement> ElementsAfterSelf (System.Xml.Linq.XName? name);
member this.ElementsAfterSelf : System.Xml.Linq.XName -> seq<System.Xml.Linq.XElement>
Public Function ElementsAfterSelf (name As XName) As IEnumerable(Of XElement)

Parameters

name
XName

The XName to match.

Returns

An IEnumerable<T> of XElement of the sibling elements after this node, in document order. Only elements that have a matching XName are included in the collection.

Examples

The following example creates an element with some complex content. It then uses this method to retrieve the sibling elements, in document order.

XElement xmlTree = new XElement("Root",  
    new XText("Text content."),  
    new XElement("Child1", "child1 content"),  
    new XElement("Child2", "child2 content"),  
    new XElement("Child3", "child3 content"),  
    new XText("More text content."),  
    new XElement("Child4", "child4 content"),  
    new XElement("Child5", "child5 content")  
);  
XElement child = xmlTree.Element("Child3");  
IEnumerable<XElement> elements = child.ElementsAfterSelf("Child4");  
foreach (XElement el in elements)  
    Console.WriteLine(el.Name);  
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:

Child4  

Remarks

This method only includes siblings in the returned collection. It does not include descendants.

This method uses deferred execution.

See also

Applies to