Good question.
In xpath . points to current node while .. points to parent node
Let's take example from w3school site -
http://www.w3schools.com/html/html_tables.aspHere Apples row data could be reached as -
$x("//div[@class='example']/table[@class='reference']//tr[1]/td[contains(text(), 'Apples')]")
or -
$x("//div[@class='example']/table[@class='reference']//tr[.]/td[contains(text(), 'Apples')]")
More over you can reach row data - 'other' with out hard coding tr count -
$x("//div[@class='example']/table[@class='reference']//tr[.]/td[contains(text(), 'Other')]")
Hence using . gives you more flexibility and would identify the element even if there row position is changed. This is also known as context node. Notice that you can also write last statement as -
$x("//div[@class='example']/table[@class='reference']//tr[.]/td[contains(., 'Other')]")
hence word 'Other' is matched against any context node. It does not have to be only text - it could be id, name or any other attribute.
A good read on this -
http://oreilly.com/perl/excerpts/system-admin-with-perl/ten-minute-xpath-utorial.html
~ seleniumtests.com