XElement.DescendantsAndSelf Metodo
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Restituisce un insieme di elementi che contengono questo elemento e tutti gli elementi discendenti di questo elemento, in ordine di documento.
Overload
| Nome | Descrizione |
|---|---|
| DescendantsAndSelf(XName) |
Restituisce una raccolta filtrata di elementi che contengono questo elemento e tutti gli elementi discendenti di questo elemento, in ordine di documento. Nella raccolta sono inclusi solo gli elementi con un XName corrispondente. |
| DescendantsAndSelf() |
Restituisce un insieme di elementi che contengono questo elemento e tutti gli elementi discendenti di questo elemento, in ordine di documento. |
Commenti
Questo metodo usa l'esecuzione posticipata.
DescendantsAndSelf(XName)
- Origine:
- XElement.cs
- Origine:
- XElement.cs
- Origine:
- XElement.cs
- Origine:
- XElement.cs
- Origine:
- XElement.cs
Restituisce una raccolta filtrata di elementi che contengono questo elemento e tutti gli elementi discendenti di questo elemento, in ordine di documento. Nella raccolta sono inclusi solo gli elementi con un XName corrispondente.
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)
Parametri
Valori restituiti
Oggetto IEnumerable<T> di XElement che contiene questo elemento e tutti gli elementi discendenti di questo elemento, in ordine di documento. Nella raccolta sono inclusi solo gli elementi con un XName corrispondente.
Esempio
Nell'esempio seguente viene creato un albero XML e quindi viene utilizzato questo oggetto .
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
In questo esempio viene generato l'output seguente:
Child
Commenti
Questo metodo usa l'esecuzione posticipata.
Vedi anche
Si applica a
DescendantsAndSelf()
- Origine:
- XElement.cs
- Origine:
- XElement.cs
- Origine:
- XElement.cs
- Origine:
- XElement.cs
- Origine:
- XElement.cs
Restituisce un insieme di elementi che contengono questo elemento e tutti gli elementi discendenti di questo elemento, in ordine di documento.
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)
Valori restituiti
Oggetto IEnumerable<T> di XElement elementi che contengono questo elemento e tutti gli elementi discendenti di questo elemento, in ordine di documento.
Esempio
Nell'esempio seguente viene creato un albero XML e quindi viene utilizzato questo oggetto .
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
In questo esempio viene generato l'output seguente:
Root
Child
GrandChild
Commenti
Questo metodo usa l'esecuzione posticipata.