title: XPath + Firebug +XML/HTML +HTML AgilityPack C#
body: <p>When using Firebug or some of the bookmarklets:</p>
  
  <pre><code>javascript:(function(){var a=document.createElement("script");a.setAttribute("src","http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js");if(typeof jQuery=="undefined"){document.getElementsByTagName("head")[0].appendChild(a)}(function(){if(typeof jQuery=="undefined"){setTimeout(arguments.callee,100)}else{jQuery("*").one("click",function(d){jQuery(this)[0].scrollIntoView();for(var e="",c=jQuery(this)[0];c&amp;&amp;c.nodeType==1;c=c.parentNode){var b=jQuery(c.parentNode).children(c.tagName).index(c)+1;b&gt;1?(b="["+b+"]"):(b="");e="/"+c.tagName.toLowerCase()+b+e}window.location.hash="#xpath:"+e;prompt('Twoje wyrazenie:',e);d.preventDefault();d.stopPropagation();jQuery("*").unbind("click",arguments.callee)})}})()})();
  </code></pre>
  
  <p>I receive a HTML's XPath. In order to parse HTML via HTML Agility Pack or Sgml, i need to convert it to XHTML (XML).
  But the problem is (i think) that XHTML's XPath is different from HTML's XPath.
  That's why Firebug's "XPath Copy" feature doesn't work when using it with </p>
  
  <pre><code>HtmlNode valueNode = doc.DocumentNode.SelectSingleNode(Firebugs_XPath);
  </code></pre>
  
  <p>For example, firebug/bookmarklet gives (if I remove tbody it won't help):</p>
  
  <pre><code>/html/body/div[2]/table/tbody/tr/td[2]/table/tbody/tr[2]/td[2]/form/table/tbody/tr[2]/td/div/table/tbody/tr/td[2]/table/tbody/tr[2]/td[2]/u
  </code></pre>
  
  <p>and proper code is (give or take):</p>
  
  <pre><code>/html/body/div/table/tr[1]/td[2]/table/tr[1]//td[2]/table[2]/tr[1]//td[2]/table/tr/tr/td[2]/u
  </code></pre>
  
  <p>My question is - how to fix that behavior, in order to make firebugXpath->HtmlAgilityPack work.
  And - is this possible, to use bookmarklet with built in C# WebBrowser component.</p>
  
  <p>I will really appreciate your help.</p>