XElement.Attribute Method

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Returns the XAttribute of this XElement that has the specified XName.

Namespace:  System.Xml.Linq
Assembly:  System.Xml.Linq (in System.Xml.Linq.dll)

Syntax

'Declaration
Public Function Attribute ( _
    name As XName _
) As XAttribute
public XAttribute Attribute(
    XName name
)

Parameters

Return Value

Type: System.Xml.Linq.XAttribute
An XAttribute that has the specified XName; nulla null reference (Nothing in Visual Basic) if there is no attribute with the specified name.

Remarks

Some axis methods return collections of elements or attributes. This method returns only a single attribute. Sometimes this is referred to as a singleton (in contrast to a collection).

Visual Basic users can use the integrated attribute axis to retrieve the value of an attribute with a specified name.

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.