title: How to select all links on a page using XPath
body: <p>I want to write a function that identifies all the links on a particular HTML page. My idea was to use XPath, by using a path such as <code>//body//a[x]</code> and incrementing x to go through the first, second, third link on the page.</p>
  
  <p>Whilst trying this out in Chrome, I load up the page <a href="http://exoplanet.eu/" rel="nofollow">http://exoplanet.eu/</a> and in the Chrome Developer Tools JS console, I call <code>$x("//body//a[1]")</code>. I expect the very first link on the page, but this returns a list of multiple anchor elements. Calling <code>$x("//body//a[2]")</code> returns two anchor elements. Calling <code>$x("//body//a[3]")</code> returns nothing.</p>
  
  <p>I was hoping that incrementing the <code>[x]</code> each time would give me each unique link one by one on the page, but they seem to be grouped. How can I rewrite this path so that I picks each anchor tag, one by one?</p>