I use a lot of XPath when locating elements in web pages using Selenium, and have moved away from using node1//node2 towards using node1/descendant::node2 more recently. What's the difference between the two methods? Is one more efficient than the other?
Example XML snippet to demonstrate:
<div id="books">
<table>
<tr><td class="title">Lord of the Rings</td><td class="author">JRR Tolkein</td></tr>
<tr><td class="title">The Hitch-Hikers Guide to the Galaxy</td><td class="author">Douglas Adams</td></tr>
</table>
</div>
So it'd be:
id('books')//td[@class='title']
or:
id('books')/descendant::td[@class='title']