Evaluating an XPath with document.evaluate() to get an array of nodes
I don't see a method to directly turn it into an array -- Array.from doesn't work, eg.  The best I could achieve was a little cleanup:



var result = document.evaluate("//*[@*[starts-with(name(), 'temp')]]", document, null, XPathResult.ANY_TYPE, null);

var node, nodes = []
while (node = result.iterateNext())
  nodes.push(node);

console.log(nodes);
&lt;div temp-callback="1" temp-post-callback="4"&gt;&lt;/div&gt;
&lt;div temp-callback="2"&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div temp-callback="8" temp-post-callback="7"&gt;&lt;/div&gt;