XPath Node Test
Here, we take a closer look at XPath node tests.
In the previous lesson we saw an example of a node test. We used the node test in our expression when selecting a node from our XML document.
In this lesson, we'll look into node tests a little more closely.
Node Test Syntax
To refresh our memory, a node test is part of an expression to retrieve one or more nodes. Here's where a node test goes within our expression:
If you have one or more predicates, your node test comes before the predicate/s:
Node Test Example
In the following example,
title is the node test:
More Node Tests
Apart from using the name of a node or a wildcard (to select unknown nodes), you can also use the following node tests:
|Selects nodes that are comments.
|Selects nodes of any type.
|Selects nodes that are processing instructions. You can specify which processing instruction to select by providing it's name in the parentheses.
|Selects a text node.