Click or drag to resize

XmlExtensionsGetAttribute Method (XElement, XName, String)

Gets the attribute value of an XML element.

Namespace:  TomsToolbox.Essentials
Assembly:  TomsToolbox.Essentials (in TomsToolbox.Essentials.dll)
Syntax
public static string? GetAttribute(
	this XElement element,
	XName name,
	string? defaultValue = null
)

Parameters

element
Type: System.Xml.LinqXElement
The element.
name
Type: System.Xml.LinqXName
The name of the attribute.
defaultValue (Optional)
Type: SystemString
The default value.

Return Value

Type: String
The value of the attribute, or the defaultValue if no such attribute exists

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type XElement. 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).
See Also