Dimitri Glazkov has produced a JavaScript implementation of DOM Level 3 XPath for Microsoft Internet Explorer. Below are some examples of what using XPath from Javascript looks like with his implementation

Now counting all links on your document is just one XPath query:

var linkCount = document.evaluate( “count(//a[@href])“, document, null, XPathResult.NUMBER_TYPE, null).getNumberValue();

So is getting a list of all images without an alt tag:

var imgIterator = document.evaluate( “//img[not(@alt)]“, document, null, XPathResult.ANY_TYPE, null);

So is finding a first LI element of al UL tags:

var firstLiIterator = document.evaluate( “//ul/li[1]“, document, null, XPathResult.ANY_TYPE, null);

Excellent work. XPath is one of the most powerful XML technologies and getting support for it in clientside HTML scripting should be a great boon to developers who do a lot of HTML processing using Javascript.