XElement.DescendantsAndSelf 메서드

정의

이 요소와 이 요소의 모든 하위 요소가 문서 순으로 들어 있는 요소 컬렉션을 반환합니다.

오버로드

DescendantsAndSelf(XName)

이 요소와 이 요소의 모든 하위 요소가 문서 순으로 들어 있는 필터링된 요소 컬렉션을 반환합니다. 일치하는 XName이 있는 요소만 컬렉션에 포함됩니다.

DescendantsAndSelf()

이 요소와 이 요소의 모든 하위 요소가 문서 순으로 들어 있는 요소 컬렉션을 반환합니다.

설명

이 메서드는 지연된 실행을 사용합니다.

DescendantsAndSelf(XName)

이 요소와 이 요소의 모든 하위 요소가 문서 순으로 들어 있는 필터링된 요소 컬렉션을 반환합니다. 일치하는 XName이 있는 요소만 컬렉션에 포함됩니다.

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

매개 변수

name
XName

일치시킬 XName입니다.

반환

IEnumerable<XElement>

이 요소와 이 요소의 모든 하위 요소가 문서 순으로 들어 있는 IEnumerable<T>XElement입니다. 일치하는 XName이 있는 요소만 컬렉션에 포함됩니다.

예제

다음 예제에서는 XML 트리를 만든 다음 이 트리를 사용합니다.

XElement xmlTree = new XElement("Root",  
    new XAttribute("Att1", "AttributeContent"),  
    new XElement("Child",  
        new XText("Some text"),  
        new XElement("GrandChild", "element content")  
    )  
);  
IEnumerable<XElement> das = xmlTree.DescendantsAndSelf("Child");  
foreach (XElement el in das)  
    Console.WriteLine(el.Name);  
Dim xmlTree As XElement = _  
    <Root Att1="AttributeContent">  
        <Child>Some text  
            <GrandChild>element content</GrandChild>  
        </Child>  
    </Root>  

Dim das As IEnumerable(Of XElement) = xmlTree.DescendantsAndSelf("Child")  

For Each el In das  
    Console.WriteLine(el.Name)  
Next  

이 예제는 다음과 같은 출력을 생성합니다.

Child  

설명

이 메서드는 지연된 실행을 사용합니다.

추가 정보

적용 대상

DescendantsAndSelf()

이 요소와 이 요소의 모든 하위 요소가 문서 순으로 들어 있는 요소 컬렉션을 반환합니다.

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

반환

IEnumerable<XElement>

이 요소와 이 요소의 모든 하위 요소가 문서 순으로 들어 있는 IEnumerable<T>XElement입니다.

예제

다음 예제에서는 XML 트리를 만든 다음 이 트리를 사용합니다.

XElement xmlTree = new XElement("Root",  
    new XAttribute("Att1", "AttributeContent"),  
    new XElement("Child",  
        new XText("Some text"),  
        new XElement("GrandChild", "element content")  
    )  
);  
IEnumerable<XElement> das =  
    from el in xmlTree.DescendantsAndSelf()  
    select el;  
foreach (XElement el in das)  
    Console.WriteLine(el.Name);  
Dim xmlTree As XElement = _  
    <Root Att1="AttributeContent">  
        <Child>Some text  
            <GrandChild>element content</GrandChild>  
        </Child>  
    </Root>  

Dim das As IEnumerable(Of XElement) = _  
    From el In xmlTree.DescendantsAndSelf() _  
    Select el  

For Each el In das  
    Console.WriteLine(el.Name)  
Next  

이 예제는 다음과 같은 출력을 생성합니다.

Root  
Child  
GrandChild  

설명

이 메서드는 지연된 실행을 사용합니다.

추가 정보

적용 대상