I\'m about to delete certain elements in an XML document, using code like the following:
NodeList nodes = ...;
for (int i = 0; i < nodes.getLength(); i++)
According to the DOM specificaion, the result of a call to node.getElementsByTagName("...") is supposed to be "live", that is, any modification made to the DOM tree will be reflected in the NodeList object. Well, for conforming implementations, that is...
NodeList and NamedNodeMap objects in the DOM are live; that is, changes to the underlying document structure are reflected in all relevant NodeList and NamedNodeMap objects.
(DOM Specification)
So, when you modify the tree structure, a conforming implementation will change the NodeList to reflect these changes.