title: Xpath on HTML: difference between HTML source and DOM model
body: <p>I use the <a href="http://plugins.jquery.com/xpath/" rel="nofollow noreferrer">jQuery Xpath</a> plugin to browse through the hierarchy of a HTML document. I do not use selectors for the reason that I need to process information of a server-side framework which tells me the Xpath to a specific element.</p>
  
  <p>Now I observed that the DOM does not necessarily represent the HTML-document's hierarchy and found the solution to this problem here: <a href="https://stackoverflow.com/questions/1678494/why-does-firebug-add-tbody-to-table">Why does firebug add &lt;tbody&gt; to &lt;table&gt;?</a>. This means, that if my HTML document does for example contain the following code:</p>
  
  <pre><code>&lt;table&gt;
    &lt;tr&gt;
      &lt;td&gt;Hello&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>My DOM will represent the latter like this:</p>
  
  <pre><code>&lt;table&gt;
    &lt;tbody&gt;
      &lt;tr&gt;
        &lt;td&gt;Hello&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>My Xpath query</p>
  
  <pre><code>jQuery(document).xpath('//table[1]/tr[1]/td[1]')
  </code></pre>
  
  <p>does therefore not longer yield a result.</p>
  
  <p>Is there a way of avoiding the synthetic elements of the DOM representation? Or a way to adjust the Xpath such that it includes the synthetic elements? Thanks for any help.</p>