Child Axis : child « XPath « XML Tutorial






The child axis is the default axis in XPath. 
The child axis selects nodes that are immediate child nodes of the context node. 

<Invoice> 
    <Date>2008-01-02</Date> 
    <Item quantity="4">QD123</Item> 
    <Item quantity="5">AC345</Item> 
</Invoice> 

If the context node is the Invoice element node, the location path child::Item or, 
in abbreviated syntax Item will return a node-set containing both Item element nodes.
To select both the Date element node and Item element node,you can write the following: 

child::* 

Or, in abbreviated syntax, use the following: 

* 

The * indicates any name, and the only nodes in the child axis that have names are element nodes. 

To select all child nodes, including comment nodes, processing instruction nodes, and text nodes: 

child::node() 

Or, in abbreviated syntax, use the following: 

node() 

If you want to select text node children of a context node, you can write the following: 

child::text() 

Or, in abbreviated syntax, use the following: 

text()








4.7.child
4.7.1.Child Axis
4.7.2.select="child::name[4]/attribute::title"
4.7.3.select=child::name[@title = editor]
4.7.4.match=child::name[@title = editor]
4.7.5.match="name[4]/@title"
4.7.6.Child of title element for the second completeTrainingCourse is
4.7.7.for-each children
4.7.8.Process the element only if the element is a child of different element
4.7.9.for-each select="child::*"