Syntax of the xml document:
Z
Z__2
Z__3
>
I dont have a reputation, so I cannot add comment to accepted answer by Blender. But his answer will not work in general. Correct version is
//x[.//z]/@name
Explanation is simple - when you use filter like [//z]
it will search for 'z' in global context, i.e. it returns true if xml contains at least one node z anywhere in xml. For example, it will select both names from xml below:
Z
Z__2
Z__3
Filter [.//z]
use context of current node (.) which is x
and return only 2nd name.