Taking the concept from [this answer](https://stackoverflow.com/a/42600459/1575353), one could get [a snapshot](https://developer.mozilla.org/en-US/docs/Introduction_to_using_XPath_in_JavaScript#Snapshots) result, create an array [filled](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fill) with dummy values and then [map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map) calls to [snapshotItem()](https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIDOMXPathResult#snapshotItem()).
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
var query = document.evaluate("//*[@*[starts-with(name(), 'temp')]]", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
var results = Array(query.snapshotLength).fill(0).map(function(element, index) {
return query.snapshotItem(index);
});
console.log(results);
<!-- language: lang-html -->
<div temp-callback="1" temp-post-callback="4"></div>
<div temp-callback="2"></div>
<div></div>
<div temp-callback="8" temp-post-callback="7"></div>
<!-- end snippet -->