I am using this in a Firefox extension and can't get it to work.
var allLinks = document.evaluate( '//a[@href]', window.document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); window.alert(allLinks);
This alerts "[object XPathResult]". However the following always returns "0". (And there are certainly links on the page.
window.alert(allLinks.snapshotLength);