node()Any node (element, text, comment, PI)
The node() test matches any node regardless of type — elements, text nodes, comments, and processing instructions. It's the most permissive node test and is often used with axes like descendant:: when you want to traverse everything in the tree.
text()Text nodes only
The text() node test selects only text nodes, filtering out elements, comments, and everything else. This is useful when you want just the textual content of an element without any child element wrappers — for example, extracting the raw text inside a <name> tag.
comment()Comment nodes
Matches XML comment nodes (<!-- ... -->). This is useful for processing or finding comments embedded in the document. Most everyday XPath work doesn't involve comments, but they matter when you need to preserve or analyze the full document structure.
processing-instruction()Processing instruction nodes
Matches processing instruction nodes (<?target data?>). These are directives to applications embedded in XML, like <?xml-stylesheet?>. You can optionally pass a name to filter by target, e.g. processing-instruction('xml-stylesheet').
*Any element node
The wildcard * matches any element node regardless of its name. Unlike node(), it only matches elements — not text, comments, or processing instructions. It's commonly used to select all child elements or as a broad filter in predicates.
@*Any attribute
Selects all attributes of the context element, regardless of name. This is useful for inspecting what attributes an element has, or for matching elements that have any attribute at all. For example, //recipe/@* returns every attribute on every <recipe>.