Cómo usar la instantánea de XPath en bucle

var xpath = "//div";
var result = document.evaluate(xpath, document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
var node = null;
var tagNames = [];
for(var i = 0; i < result.snapshotLength; i++) {
  var node = result.snapshotItem(i);
  tagNames.push(node.localName);
}
document.querySelector("output").textContent = tagNames.join(", ");
Braxton Bell