title: What's the difference between //node and /descendant::node in xpath?
body: <p>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?</p>
  
  <p>Example XML snippet to demonstrate:</p>
  
  <pre><code>&lt;div id="books"&gt;
    &lt;table&gt;
      &lt;tr&gt;&lt;td class="title"&gt;Lord of the Rings&lt;/td&gt;&lt;td class="author"&gt;JRR Tolkein&lt;/td&gt;&lt;/tr&gt;
      &lt;tr&gt;&lt;td class="title"&gt;The Hitch-Hikers Guide to the Galaxy&lt;/td&gt;&lt;td class="author"&gt;Douglas Adams&lt;/td&gt;&lt;/tr&gt;
    &lt;/table&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>So it'd be:</p>
  
  <pre>id('books')//td[@class='title']</pre>
  
  <p>or:</p>
  
  <pre>id('books')/descendant::td[@class='title']</pre>