XNode.ElementsAfterSelf 方法

定義

依照文件順序,傳回這個節點之後同層級項目的集合。

多載

ElementsAfterSelf()

依照文件順序,傳回這個節點之後同層級項目的集合。

ElementsAfterSelf(XName)

依照文件順序,傳回這個節點之後同層級項目之篩選的集合。 集合中只會包含具有相符之 XName 的項目。

備註

這個方法會使用延後的執行。

ElementsAfterSelf()

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

依照文件順序,傳回這個節點之後同層級項目的集合。

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)

傳回

IEnumerable<T>,屬於這個節點之後同層級項目 (依照文件順序) 的 XElement

範例

下列範例會建立具有一些複雜內容的專案。 然後,它會使用這個方法來依檔順序擷取節點。

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  

這個範例會產生下列輸出:

Child4  
Child5  

備註

這個方法只會在傳回的集合中包含同層級。 它不包含子系。

這個方法會使用延後的執行。

另請參閱

適用於

ElementsAfterSelf(XName)

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

依照文件順序,傳回這個節點之後同層級項目之篩選的集合。 集合中只會包含具有相符之 XName 的項目。

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)

參數

name
XName

要比對的 XName

傳回

IEnumerable<T>,屬於這個節點之後同層級項目 (依照文件順序) 的 XElement。 集合中只會包含具有相符之 XName 的項目。

範例

下列範例會建立具有一些複雜內容的專案。 然後,它會使用這個方法來依檔順序擷取同層級專案。

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  

這個範例會產生下列輸出:

Child4  

備註

這個方法只會在傳回的集合中包含同層級。 它不包含子系。

這個方法會使用延後的執行。

另請參閱

適用於