title: Performance of XPath vs DOM
body: <p>Would anyone enlighten me some comprehensive performance comparison between XPath and DOM in different scenarios? I've read some questions in SO like <a href="https://stackoverflow.com/questions/4742663/xpath-vs-dom-api-which-one-has-a-better-performance">xPath vs DOM API, which one has a better performance</a> and <a href="https://stackoverflow.com/questions/1063306/xpath-or-queryselector">XPath or querySelector?</a>. None of them mentions specific cases. Here's somethings I could start with.</p>
  
  <ol>
  <li>No iteration involved. getElementById(foobar) vs //*[@id='foobar']. Is former constantly faster than latter? What if the latter is optimized, e.g. /html/body/div[@id='foo']/div[@id='foobar']?</li>
  <li>Iteration involved. getElementByX then traverse through child nodes vs XPath generate snapshot then traverse through snapshot items.</li>
  <li>Axis involved. getElementByX then traverse for next siblings vs //following-sibling::foobar.</li>
  <li>Different implementations. Different browsers and libraries implement XPath and DOM differently. Which browser's implementation of XPath is better?</li>
  </ol>
  
  <p>As the answer in <a href="https://stackoverflow.com/questions/4742663/xpath-vs-dom-api-which-one-has-a-better-performance">xPath vs DOM API, which one has a better performance</a> says, average programmer may screw up when implementing complicated tasks (e.g. multiple axes involved) in DOM way while XPath is guaranteed optimized. Therefore, my question only cares about the simple selections that can be done in both ways.</p>
  
  <p>Thanks for any comment.</p>