What does an XPath expression mean to select all elements, text nodes, and comment nodes in the same order as in the document?
The following efficiently selects all elements, but not text nodes and comment nodes:
var result = document.evaluate('//*', document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null),
index = -1;
while (++index < result.snapshotLength) {
console.log(result.snapshotItem(index));
}
Is it possible to do something like the following? (Note: this is a non-functional pseudo code.)
document.evaluate('//* and text() and comment()');
source
share