Propriedade de eixo descendente XML (Visual Basic)
Fornece acesso para os descendentes dos seguintes procedimentos: um XElementoobjeto, um XDocumentobjeto, uma coleção de XElement objetos, ou uma coleção de XDocument objetos.
object...<descendant>
Parts
object
Required. An XElement object, an XDocument object, a collection of XElement objects, or a collection of XDocument objects....<
Required. Denotes the start of a descendant axis property.descendant
Required. Name of the descendant nodes to access, of the form [prefix:]name.Part
Description
prefix
Optional. XML namespace prefix for the descendant node. Must be a global XML namespace that is defined by using an Imports statement.
name
Required. Local name of the descendant node. See Nomes de elementos e atributos XML declarados (Visual Basic).
>
Required. Denotes the end of a descendant axis property.
Valor de retorno
Uma coleção de XElement objetos.
Comentários
You can use an XML descendant axis property to access descendant nodes by name from an XElement or XDocument object, or from a collection of XElement or XDocument objects. Use the XML Value property to access the value of the first descendant node in the returned collection. For more information, see Propriedade de valor XML (Visual Basic).
O Visual Basic compilador converte as propriedades de eixo descendente em chamadas para o Descendants método.
XML Namespaces
The name in a descendant axis property can use only XML namespaces declared globally with the Imports statement. It cannot use XML namespaces declared locally within XML element literals. For more information, see Instrução Imports (Namespace XML).
Exemplo
The following example shows how to access the value of the first descendant node named name and the values of all descendant nodes named phone from 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 homePhone = From phone In contacts...<phone>
Select phone.Value
Console.WriteLine("Home Phone = {0}", homePhone(0))
This code displays the following text:
Name: Patrick Hines
Home Phone = 206-555-0144
The following example declares ns as an XML namespace prefix. It then uses the prefix of the namespace to create an XML literal and access the value of the first child node with the qualified name ns:name.
Imports <xmlns:ns = "http://SomeNamespace">
Class TestClass2
Shared Sub TestPrefix()
Dim contacts =
<ns:contacts>
<ns:contact>
<ns:name>Patrick Hines</ns:name>
</ns:contact>
</ns:contacts>
Console.WriteLine("Name: " & contacts...<ns:name>.Value)
End Sub
End Class
This code displays the following text:
Name: Patrick Hines
Consulte também
Referência
Conceitos
Nomes de elementos e atributos XML declarados (Visual Basic)