Your XPath,
/stationary/*/name/text()
will only select the text nodes contained in the name
element under textbook
because /*
selects a child element, but the other name
element is a grandchild of stationary
, not a child of it.
The simplest change would be to replace /*/
with //
(as mentioned by
@GillesQuenot, +1),
/stationary//name/text()
which will select along the descendant-or-self axis, so it'll select grandchildren, and you'll get both name
elements' text()
nodes.
Do note that you say you're trying to get name
elements, so technically you ought to drop the text()
step,
/stationary//name
which will select all name
element descendants of the stationary
element. Then, as a final note, this XPath (as mentioned by @TimBiegeleisen, +1),
//name
will select all name
elements in the document regardless of the root element.