removeNext Method
Removes the next node.
JScript Syntax
var objXMLDOMNode = objXMLDOMSelection.removeNext();
Example
Note
You can use books.xml to run this sample code.
var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.3.0");
var oSelection;
xmlDoc.setProperty("SelectionLanguage", "XPath");
xmlDoc.async = false;
xmlDoc.load("books.xml");
if (xmlDoc.parseError.errorCode != 0) {
var myErr = xmlDoc.parseError;
WScript.Echo("You have error " + myErr.reason);
} else {
oSelection = xmlDoc.selectNodes("//book");
while (oSelection.peekNode() != null) {
oSelection.removeNext();
}
WScript.Echo(xmlDoc.xml);
}
Output
<?xml version="1.0"?>
<catalog>
</catalog>
C/C++ Syntax
HRESULT removeNext(IXMLDOMNode ** ppNode);
Parameters
ppNode
[out, retval]
The node that was removed, or Null if there is no nextNode
to remove. If the parameter is Null, the removed node is not returned, but is still removed.
Return Values
S_OK
The value returned if the method is successful.
S_FALSE
The value returned if no nodes left in the selection.
E_PENDING
The value returned if all nodes cannot be found at this time (in which case no nodes are removed).
Remarks
The removeNext
method is equivalent to the following (except that it also works for attributes).
var node = list.peekNode();node.parentNode.removeChild(node);
The side effect is that the length of the collection is decremented and the nextNode
and item
methods will not return it because it has been removed.
Versioning
Implemented in: MSXML 3.0 and MSXML 6.0