Click or drag to resize

XmlExtensionsWhereAttribute Method

Finds all attributes in an enumeration of XElement items that match the specified attributeName.

Namespace: GSF.Xml
Assembly: GSF.Core (in GSF.Core.dll) Version: 2.4.254-beta+b1c32a8191971a5ec09744a3eb270cb5508e892c
Syntax
public static IEnumerable<Tuple<XElement, string>> WhereAttribute(
	this IEnumerable<XElement> source,
	string attributeName
)
View Source

Parameters

source  IEnumerableXElement
Set of XElement values to search.
attributeName  String
Attribute name to match.

Return Value

IEnumerableTupleXElement, String
Matching sets of XElement items and associated attribute values.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IEnumerableXElement. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
Remarks
When used in conjunction with the Is(IEnumerableTupleXElement, String, String, Boolean) extension, allows for expressions like:
C#
var globals = XDocument.Load(configFile)
    .Descendants("SettingsGroup")
    .WhereAttribute("Type").Is("Globals");
See Also