Hi Folks,
Can anyone explain me whether we can use multiple predicates in the path expression.
In the below path, // indicates searching for the node in XML document irrespective of its position, but I didn't understand why 'starts-with' function is placed in [] brackets. Even though it's working fine, can anyone explain how it works?

Here is the path for your reference.
path="//*[starts-with(name(), 'FSA')][position()=//count/text()]/@SCIObjectID"

Thanks in Advance......

path="//*[starts-with(name(), 'FSA')][position()=//count/text()]/@SCIObjectID"

[] a Predicates content a false true

starts-with(name(), 'FSA') when the current tagname
a FSA****

* are any sign of the alpabeth
then second predicate
compare positionnummer with current Tagnode child count value

then alle predicate are true the parser found the arttirbut


Yes, multiple precidates are permitted in a step. In your example you have two adjacant predicates.

From XPath 2.0 3.2.1
A step is a part of a path expression that generates a sequence of items and then filters the sequence by zero or more predicates. The value of the step consists of those items that satisfy the predicates, working from left to right. A step may be either an axis step or a filter expression.

[starts-with(name(), 'FSA')] is a predicate as indicated by the square brackets.

From XPath 2.0 3.2.2
A predicate consists of an expression, called a predicate expression, enclosed in square brackets. A predicate serves to filter a sequence, retaining some items and discarding others. In the case of multiple adjacent predicates, the predicates are applied from left to right, and the result of applying each predicate serves as the input sequence for the following predicate.

This article has been dead for over six months. Start a new discussion instead.