Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

SecurityElement.Attribute Method

Finds an attribute by name in an XML element.

Namespace:  System.Security
Assembly:  mscorlib (in mscorlib.dll)

public string Attribute(
	string name
)

Parameters

name
Type: System.String

The name of the attribute for which to search.

Return Value

Type: System.String
The value associated with the named attribute, or null if no attribute with name exists.

ExceptionCondition
ArgumentNullException

The name parameter is null.

With XML as follows, Attribute("B") would return "456".

<thetag A="123" B="456" C="789">text</thetag>

The following code shows the use of the Attribute method to find an attribute by name. This code example is part of a larger example provided for the SecurityElement class.

string xmlCreationDate = xmlElement.Attribute("creationdate");

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft