Extensions.DescendantsAndSelf 方法

定义

返回源集合中的每个元素及其所有子代元素的集合。

重载

DescendantsAndSelf(IEnumerable<XElement>)

返回元素集合,其中包含源集合中的每个元素及其子代元素。

DescendantsAndSelf(IEnumerable<XElement>, XName)

返回经过筛选的元素集合,其中包含源集合中的每个元素及其子代元素。 集合中仅包括具有匹配 XName 的元素。

注解

尽管 Visual Basic 具有子代元素的集成 XML 轴,但没有具有此方法语义的集成轴。

此方法使用延迟执行。

DescendantsAndSelf(IEnumerable<XElement>)

Source:
Extensions.cs
Source:
Extensions.cs
Source:
Extensions.cs

返回元素集合,其中包含源集合中的每个元素及其子代元素。

C#
public static System.Collections.Generic.IEnumerable<System.Xml.Linq.XElement> DescendantsAndSelf (this System.Collections.Generic.IEnumerable<System.Xml.Linq.XElement> source);
C#
public static System.Collections.Generic.IEnumerable<System.Xml.Linq.XElement> DescendantsAndSelf (this System.Collections.Generic.IEnumerable<System.Xml.Linq.XElement?> source);

参数

source
IEnumerable<XElement>

一个包含源集合的 IEnumerable<T>XElement

返回

IEnumerable<T>XElement,其中包含源集合中的每个元素及其子代元素。

注解

尽管 Visual Basic 具有用于子元素的集成 XML 轴,但没有具有此方法语义的集成轴,因此 Visual Basic 用户必须显式使用此轴方法。

此方法使用延迟执行。

另请参阅

适用于

.NET 9 和其他版本
产品 版本
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0

DescendantsAndSelf(IEnumerable<XElement>, XName)

Source:
Extensions.cs
Source:
Extensions.cs
Source:
Extensions.cs

返回经过筛选的元素集合,其中包含源集合中的每个元素及其子代元素。 集合中仅包括具有匹配 XName 的元素。

C#
public static System.Collections.Generic.IEnumerable<System.Xml.Linq.XElement> DescendantsAndSelf (this System.Collections.Generic.IEnumerable<System.Xml.Linq.XElement> source, System.Xml.Linq.XName name);
C#
public static System.Collections.Generic.IEnumerable<System.Xml.Linq.XElement> DescendantsAndSelf (this System.Collections.Generic.IEnumerable<System.Xml.Linq.XElement?> source, System.Xml.Linq.XName? name);

参数

source
IEnumerable<XElement>

一个包含源集合的 IEnumerable<T>XElement

name
XName

要匹配的 XName

返回

IEnumerable<T>XElement,其中包含源集合中的每个元素及其子代元素。 集合中仅包括具有匹配 XName 的元素。

注解

尽管 Visual Basic 具有用于子元素的集成 XML 轴,但没有具有此方法语义的集成轴,因此 Visual Basic 用户必须显式使用此轴方法。

此方法使用延迟执行。

另请参阅

适用于

.NET 9 和其他版本
产品 版本
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0