Given the following XML file :
3
1- Find direct descendant of elements which are direct descendant of direct descendants of root element In this case
/a/b[1]/c
/a/b[1]/d
/a/b[2]/c
/a/b[2]/d
/a/b[2]/f
are your answer.
2- all descendant (direct or indirect) element under first level of elements In this case
/a/b[1]/c
/a/b[1]/d
/a/b[2]/c
/a/b[2]/d
/a/b[2]/d/e
/a/b[2]/f
are your answer.
3- find all attributes which belong all descendants of direct descendants of first level elements In this case
/b[1]/@n
/b[1]/@o
/b[1]/c/@p
/b[2]/@n
/b[2]/@o
/b[2]/c/@p
/b[2]/d/@q
/b[2]/d/e/@r
/b[2]/f/@s
are your answer.
As you can see here answer to 3rd case is 9, since you wrote it wrong. To make it return your must change it as count(/*/*/*/@*)
EDIT: corrected indices as noted by Mimo.