XML Value Property (Visual Basic)
Provides access to the value of the first element of a collection of XElement objects.
A String that contains the value of the first element of the collection, or Nothing if the collection is empty.
The Value property makes it easy to access the value of the first element in a collection of XElement objects. This property first checks whether the collection contains at least one object. If the collection is empty, this property returns Nothing. Otherwise, this property returns the value of the Value property of the first element in the collection.
When you access the value of an XML attribute using the '@' identifier, the attribute value is returned as a String and you do not need to explicitly specify the Value property.
To access other elements in a collection, you can use the XML extension indexer property. For more information, see Extension Indexer Property (Visual Basic).
Most users will not have to implement IEnumerable<T>, and can therefore ignore this section.
The Value property is an extension property for types that implement IEnumerable(Of XElement). The binding of this extension property is like the binding of extension methods: if a type implements one of the interfaces and defines a property that has the name "Value", that property has precedence over the extension property. In other words, this Value property can be overridden by defining a new property in a class that implements IEnumerable(Of XElement).
The following example shows how to get the value of an XML attribute from a collection of XAttribute objects. The example uses the attribute axis property to display the value of the type attribute for all of the the phone elements.