I think these answers may need a little bit of an update, though, I want to note, that my answer is going to be purley XPath related. I have no knowledge about Java WebDrivers.
You can't do this with XPath 1.0. But you can do this with XPath, starting from version 2.0 (XPath and XQuery Functions and Operators 3.1 is the official documentation of the XPath functions for XPath 3,1, which, at this writing, is the current implementation. You can also find a, much more accessible, reference here.). The function, to do so is:
fn:doc($uri as xs:string?) as document-node()?
which would return the document as XML document node. So, your above query would be named:
doc("www.example.com")/html/body/div[3]/table/tbody/tr[2]/td/table/tbody/tr[2]/td[3]
However, this does not result in an XML fragment being produced. Your client still would download the full HTML document and then, locally, extract the requested path.
To query an explicit XPath from a remote XML resource would require a few steps:
- a change in the URI format specification [RFC 3986], that introduces an escape character, that marks an XPath expression within the URI. A single character, that tells the URI receiver: "all text after this character is an XPath expression". There was an interesting article regarding this, "Can a URL contain an XPath?", by Rick Jelliffe of Schematron fame on O'Reilly, but O'Reilly seems to have killed off those articles, the old links lead to their main landing page.
- web servers, that could evaluate this URI and serve back the requested XML fragment (instead the whole document). This also would mean, that in your case, the
fn:doc() function would not be needed (and the wrong tool for the job anyway, since, as stated, it always returns the full document).
- last, but not least, a client, that can deal with XML fragments.
Sadly, these developments have been abandoned with the introduction of HTML5.