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.
<code>
path="//*[starts-with(name(), 'FSA')][position()=//count/text()]/@SCIObjectID"
</code>

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

@SCIObjectID

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.

Thanks for the clear explaination folks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.