XPath tutorial

Child axis

The child axis contains the children of the context node. The child axis is the default axis and it can be omitted.

Example 1

XPath Expression: Equivalent of /child::AAA
/AAA
XML:
<?xml version="1.0">
     <AAA>
          <BBB/>
          <CCC/>
     </AAA>

Example 2

XPath Expression: Equivalent of /AAA

/child::AAA
XML:
<?xml version="1.0">
     <AAA>
          <BBB/>
          <CCC/>
     </AAA>

Example 3

XPath Expression: Equivalent of /child::AAA/child::BBB

/AAA/BBB
XML:
<?xml version="1.0">
     <AAA>
          <BBB/>
          <CCC/>
     </AAA>

Example 4

XPath Expression: Equivalent of /AAA/BBB

/child::AAA/child::BBB
XML:
<?xml version="1.0">
     <AAA>
          <BBB/>
          <CCC/>
     </AAA>

Example 5

XPath Expression: Both possibilities can be combined

/child::AAA/BBB
XML:
<?xml version="1.0">
     <AAA>
          <BBB/>
          <CCC/>
     </AAA>
C# code:
// BasicSyntax - /xpath/basicsyntax.cs
// Copyright 2003 by Johannes Roith

using System;
using System.Xml.XPath;

class BasicSyntax {
        static void Main() {
                
        }

}