description | title | ms.date | f1_keywords | helpviewer_keywords | ms.assetid | ||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Learn more about: XML Child Axis Property (Visual Basic) |
XML Child Axis Property |
07/20/2015 |
|
|
89a59d00-985e-4f5c-b59f-29b47bad11cb |
Provides access to the children of one of the following: an xref:System.Xml.Linq.XElement object, an xref:System.Xml.Linq.XDocument object, a collection of xref:System.Xml.Linq.XElement objects, or a collection of xref:System.Xml.Linq.XDocument objects.
object.<child>
Term | Definition |
---|---|
object |
Required. An xref:System.Xml.Linq.XElement object, an xref:System.Xml.Linq.XDocument object, a collection of xref:System.Xml.Linq.XElement objects, or a collection of xref:System.Xml.Linq.XDocument objects. |
.< | Required. Denotes the start of a child axis property. |
child |
Required. Name of the child nodes to access, of the form [prefix:]name .- Prefix - Optional. XML namespace prefix for the child node. Must be a global XML namespace defined with an Imports statement.- Name - Required. Local child node name. See Names of Declared XML Elements and Attributes. |
> | Required. Denotes the end of a child axis property. |
A collection of xref:System.Xml.Linq.XElement objects.
You can use an XML child axis property to access child nodes by name from an xref:System.Xml.Linq.XElement or xref:System.Xml.Linq.XDocument object, or from a collection of xref:System.Xml.Linq.XElement or xref:System.Xml.Linq.XDocument objects. Use the XML Value
property to access the value of the first child node in the returned collection. For more information, see XML Value Property.
The Visual Basic compiler converts child axis properties to calls to the xref:System.Xml.Linq.XContainer.Elements%2A method.
The name in a child axis property can use only XML namespace prefixes declared globally with the Imports
statement. It cannot use XML namespace prefixes declared locally within XML element literals. For more information, see Imports Statement (XML Namespace).
The following example shows how to access the child nodes named phone
from the contact
object.
[!code-vbVbXMLSamples#17]
This code displays the following text:
Home Phone = 206-555-0144
The following example shows how to access the child nodes named phone
from the collection returned by the contact
child axis property of the contacts
object.
[!code-vbVbXMLSamples#18]
This code displays the following text:
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 first child node with the qualified name ns:name
.
[!code-vbVbXMLSamples#19]
This code displays the following text:
Patrick Hines
- xref:System.Xml.Linq.XElement
- XML Axis Properties
- XML Literals
- Creating XML in Visual Basic
- Names of Declared XML Elements and Attributes