XPath in Mozilla (25 Oct 2004)

There really should be better documentation for this sort of thing. Maybe there is, but Google doesn't find it very well. Anyway...

var result = xmldocument.evaluate(xpath query, 
  xpath root element,
  null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);

The xmldocument seems to be able to be any such DOM object - it doesn't have to be connected with the root element so it could, for example, be document. Note that a general Node object wont do - they don't have an evaluate method.

Then the result object has a property snapshotLength giving the number of results and a given result Node object can be obtained by calling snapshotItem(i).