XElement.DescendantNodesAndSelf Yöntem
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
Bu öğeyi ve bu öğenin tüm alt düğümlerini içeren bir düğüm koleksiyonunu belge sırasına göre döndürür.
public:
System::Collections::Generic::IEnumerable<System::Xml::Linq::XNode ^> ^ DescendantNodesAndSelf();
public System.Collections.Generic.IEnumerable<System.Xml.Linq.XNode> DescendantNodesAndSelf();
member this.DescendantNodesAndSelf : unit -> seq<System.Xml.Linq.XNode>
Public Function DescendantNodesAndSelf () As IEnumerable(Of XNode)
Döndürülenler
Bunlardan biri IEnumerable<T>XNode , belge sırasına göre bu öğeyi ve bu öğenin tüm alt düğümlerini içerir.
Örnekler
Aşağıdaki örnek bir XML ağacı oluşturur ve sonra bunu kullanır.
XElement xmlTree = new XElement("Root",
// Attributes are not nodes, so will not be returned by DescendantNodesAndSelf.
new XAttribute("Att1", "AttributeContent"),
new XElement("Child",
new XText("Some text"),
new XElement("GrandChild", "element content")
)
);
IEnumerable<XNode> dnas =
from node in xmlTree.DescendantNodesAndSelf()
select node;
foreach (XNode node in dnas)
{
if (node is XElement)
Console.WriteLine((node as XElement).Name);
else
Console.WriteLine(node);
}
Dim xmlTree As XElement = _
<Root Att1="AttributeContent">
<Child>Some text<GrandChild>element content</GrandChild>
</Child>
</Root>
Dim dnas As IEnumerable(Of XNode) = _
From node In xmlTree.DescendantNodesAndSelf() _
Select node
For Each node In dnas
If TypeOf node Is XElement Then
Console.WriteLine(DirectCast(node, XElement).Name)
Else
Console.WriteLine(node)
End If
Next
Bu örnek aşağıdaki çıkışı oluşturur:
Root
Child
Some text
GrandChild
element content
Açıklamalar
Bu yöntem ertelenen yürütmeyi kullanır.