Export (0) Print
Expand All

How to: Retrieve a Collection of Attributes (LINQ to XML)

This topic introduces the Attributes method. This method retrieves the attributes of an element.

The following example shows how to iterate through the collection of attributes of an element.

Dim val = _
    <Value ID="1243" Type="int" ConvertableTo="double">100</Value>
Dim listOfAttributes As IEnumerable(Of XAttribute) = _
    From att In val.Attributes() _
    Select att
For Each att As XAttribute In listOfAttributes
    Console.WriteLine(att)
Next

This code produces the following output:

ID="1243"
Type="int"
ConvertableTo="double"
Show:
© 2014 Microsoft