Język

XElement.DescendantsAndSelf Metoda

Definicja

Zwraca kolekcję elementów, które zawierają ten element, oraz wszystkie elementy podrzędne tego elementu w kolejności dokumentu.

Przeciążenia

Nazwa Opis
DescendantsAndSelf(XName)

Zwraca odfiltrowaną kolekcję elementów, które zawierają ten element, oraz wszystkie elementy podrzędne tego elementu w kolejności dokumentu. W kolekcji znajdują się tylko elementy, które mają pasujący XName.

DescendantsAndSelf()

Zwraca kolekcję elementów, które zawierają ten element, oraz wszystkie elementy podrzędne tego elementu w kolejności dokumentu.

Uwagi

Ta metoda używa wykonania odroczonego.

DescendantsAndSelf(XName)

Źródło:
XElement.cs
Źródło:
XElement.cs
Źródło:
XElement.cs
Źródło:
XElement.cs
Źródło:
XElement.cs

Zwraca odfiltrowaną kolekcję elementów, które zawierają ten element, oraz wszystkie elementy podrzędne tego elementu w kolejności dokumentu. W kolekcji znajdują się tylko elementy, które mają pasujący 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)

Parametry

name
XName

Element XName do dopasowania.

Zwraca

IEnumerable<T> Element XElement zawierający ten element i wszystkie elementy podrzędne tego elementu w kolejności dokumentu. W kolekcji znajdują się tylko elementy, które mają pasujący XName.

Przykłady

Poniższy przykład tworzy drzewo XML, a następnie używa tego elementu .

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

Ten przykład generuje następujące wyniki:

Child

Uwagi

Ta metoda używa wykonania odroczonego.

Zobacz też

Dotyczy

DescendantsAndSelf()

Źródło:
XElement.cs
Źródło:
XElement.cs
Źródło:
XElement.cs
Źródło:
XElement.cs
Źródło:
XElement.cs

Zwraca kolekcję elementów, które zawierają ten element, oraz wszystkie elementy podrzędne tego elementu w kolejności dokumentu.

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)

Zwraca

Element IEnumerable<T> zawierający XElement ten element i wszystkie elementy podrzędne tego elementu w kolejności dokumentu.

Przykłady

Poniższy przykład tworzy drzewo XML, a następnie używa tego elementu .

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

Ten przykład generuje następujące wyniki:

Root
Child
GrandChild

Uwagi

Ta metoda używa wykonania odroczonego.

Zobacz też

Dotyczy