I have a 1000 entry document whose format is something like:
The correct solution is to detach the node right after you call item(i), like so:
Node node = results.item(index) node.getParentNode().removeChild(node) nodes.add(node)
See XPath.evaluate performance slows down (absurdly) over multiple calls