At some places, I saw element like following -
//a[.='Assignment']
Generally we've syntax like - //tagName[attributeKey='attributeValue']
or //tagName[text()='textValue']
But what is intention of .
in xpath //a[.='Assignment']
?
At some places, I saw element like following -
//a[.='Assignment']
Generally we've syntax like - //tagName[attributeKey='attributeValue']
or //tagName[text()='textValue']
But what is intention of .
in xpath //a[.='Assignment']
?
I'll use XPath 2.0 terminology here: XPath 1.0 has different terminology but the effect of the expression is the same.
"." refers to the context item: that is, the a
element that you are testing against the predicate. Its value here is a node. When a node is used as an argument of "=", it is atomized, which means (unless your code is schema-aware, which is unlikely) that the string value of the node is compared with the other operand of "=". The string value of an element is the concatenation of all its descendant text nodes.
It sounds like you don't have ready access to an XPath reference. There are quite a few good books that cover XPath, there are online tutorials (which are highly variable in quality) and the W3C specification itself (especially for XPath 1.0) is surprisingly easy reading.