The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

XElement.Attributes Method

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Returns a collection of attributes of this element.

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

public IEnumerable<XAttribute> Attributes()

Return Value

Type: System.Collections.Generic.IEnumerable<XAttribute>
An IEnumerable<T> of XAttribute of attributes of this element.

The attributes in the returned collection are in the order that they were added to the element. If the XML tree was parsed from XML, the attributes are returned in document order.

This method uses deferred execution.

The following example creates an element with two attributes. It then uses this axis method to retrieve all attributes of the element.

StringBuilder output = new StringBuilder();
XElement xmlTree = new XElement("Root",
    new XAttribute("Att1", "content1"),
    new XAttribute("Att2", "content2")
IEnumerable<XAttribute> attList =
    from at in xmlTree.Attributes()
    select at;
foreach (XAttribute att in attList)
    output.Append(att + Environment.NewLine);

OutputTextBlock.Text = output.ToString();

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone