How to: Access XML Descendant Elements (Visual Basic)
This example shows how to use a descendant axis property to access all XML elements that have a specified name and that are contained under an XML element. In particular, it uses the Value property to get the value of the first element in the collection that the name descendant axis property returns. The name descendant axis property gets all elements named name that are contained in the contacts object. This example also uses the phone descendant axis property to access all descendants named phone that are contained in the contacts object.
Dim contacts As XElement = _ <contacts> <contact> <name>Patrick Hines</name> <phone type="home">206-555-0144</phone> <phone type="work">425-555-0145</phone> </contact> </contacts> Console.WriteLine("Name: " & contacts...<name>.Value) Dim phoneTypes As XElement = _ <phoneTypes> <%= From phone In contacts...<phone> _ Select <type><%= phone.@type %></type> _ %> </phoneTypes> Console.WriteLine(phoneTypes)