Predicates in XPath Expressions

You can use predicates in XPath expressions to process a subset of element instances. You can use a position predicate or attribute values predicate with an element, but not both. You can also use a wildcard to define the attribute value.
Position predicate
The position predicate indicates the instance of the element to use in the file. Use a position predicate when the element appears multiple times in a file, and you want to use a particular instance based on the position of the instances in the file, e.g. the first, second, or third time the element appears in the file.
Use the following syntax to specify a position predicate:
/<element>[<position number>]
For example, say the contact element appears multiple times in the file, but you only care about the address data in the first instance in the file. Then you can use a predicate for the element as follows:
/root/contact[1]/address
Attribute value predicate
The attribute value predicate limits the data to elements with the specified attribute value. Use the attribute value predicate when you want to specify an element with a particular attribute values or an element that simply has an attribute value defined.
Use the following syntax to specify an attribute value predicate:
/<element>[@<attribute name>='<attribute value>']
You can use the asterisk wildcard as the attribute value. Surround the value in single quotation marks.
For example, if you only wanted server data with a region attribute set to "west", you can add the region attribute as follows:
/*/server[@region='west']