Is there a tool or browser plugin (not sure if Firebug can do this) that will let you open a web page and then using the tool/plugin to search using an xpath query and it will highlight the things on the screen that match your query?
Firebug offers the $x()
convenience function, which dumps the results of an xpath query to the console (where they can be hovered over to highlight). Not quite what you want though.
And then there's XPather, which does a whole lot more.
The XPathVisualizer (abbreviated as XPV in this answer) does exactly what is described. There are two separate versions: a version for IE and a version for Mozilla/Firefox.
One starts the XPV by doubleclicking on its filename (.htm) in Windows explorer.
Then one chooses an XML file that is dispayed in a very similar way to the IE display of XML files.
Then one can enter any XPath expression and all selected nodes are highlighted.
There are additional capabilities, such as defining variables and xsl:key
-s that once defined can be referenced within an XPath expression. Namespace prefixes are automatically discovered and bound to the correct namespace-uri.
XPath expressions that evaluate to atomic values (not nodes) are also displayed as result of any such XPath expression.
This tool has been used for many years by thousands of people to learn XPath the fun way.
It comes, of course, with full source code (Javascript + XSLT).
The XPV for IE can be downloaded here.
The XPV for Mozilla/Firefox can be downloaded here.