Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the use of ., in XPath?

Tags:

xml

xpath

Why is a comma used after the period in certain XPath expressions? Here is an example:

Set nlist = doc.selectNodes("//book/author/first-name[starts-with(.,'M')]")

I tried to search for this with Google, but the literal "" operators don't seem to like periods or commas.

like image 899
NielsInc Avatar asked May 30 '11 19:05

NielsInc


1 Answers

In XPath the . mark stands for context node. The context node is usually the same of the current node (current() function) being processed but it might be situations where it's different. This is not really obvious when you deal with XPath only, but it happens when using XSLT. See this question in SO explaining such a difference.

like image 180
Emiliano Poggi Avatar answered Oct 16 '22 10:10

Emiliano Poggi