In XSL 1.0, descendant-or-self will select ALL descendants and the current node. What if you want to select only the immediate children and the current node (i.e. child-or-self)?
Is that possible with XPATH?
In XSL 1.0, descendant-or-self will select ALL descendants and the current node. What if you want to select only the immediate children and the current node (i.e. child-or-self)?
Is that possible with XPATH?
In XPath 1.0 or later use:
In XPath 2.0 or later use:
An incorrect answer would be:
because this selects only those children of
SomeExpression
that are elements, whileSomeExpression
may have other children too -- as text-nodes, comment nodes, processing-instruction nodes.Also incorrect is:
This doesn't select the immediate children of
./SomeExpression
and it doesn't select the immidiate children of./*/SomeExpression
.