Part 2 of XPath Location Steps: Node Tests

When constructing patterns, you can use names of nodes as node tests, or the wild card * to select any element node. For example, the expression child::*/child::NAME selects all <NAME> elements that are grandchildren of the context node. In addition to node names and the wild card character, you can also use these node tests in XPath, just as you can in match patterns:

  • The comment()node test selects comment nodes.

  • The node()node test selects any type of node.

  • The processing-instruction()node test selects a processing instruction node. You specify the name of the processing instruction to select in the parentheses.

  • The text()node test selects a text node.

For example, the following stylesheet finds all ...

Get Inside XSLT now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.