Select an XML element regardless of level with XPATH

You are looking for the descendant axis:

the descendant axis contains the descendants of the context node; a descendant is a child or a child of a child and so on; thus the descendant axis never contains attribute or namespace nodes

In your case: /descendant:t

Of course, as others have answered, there is an abbreviated syntax for this:

// is short for /descendant-or-self::node()/. For example, //para is short for /descendant-or-self::node()/child::para and so will select any para element in the document (even a para element that is a document element will be selected by //para since the document element node is a child of the root node)


You can use // to select all nodes from the current node. So //text() would select all text nodes.

If you wanted all t elements you would do //t. If you wanted to do do all t elements from a certain point you might then do /x/y//t.


just //t if you want all <t> tags

Tags:

Xml

Xpath