removeNext Method

MSXML 5.0 SDK

Microsoft XML Core Services (MSXML) 5.0 for Microsoft Office - DOM Reference

removeNext Method

Removes the next node.

[Script]

Script Syntax

var objXMLDOMNode = objXMLDOMSelection.removeNext();

Example

var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.5.0");
var oSelection;
xmlDoc.setProperty("SelectionLanguage", "XPath");
xmlDoc.async = false;
xmlDoc.load("books.xml");
if (xmlDoc.parseError.errorCode != 0) {
   var myErr = xmlDoc.parseError;
   alert("You have error " + myErr.reason);
} else {
   oSelection = xmlDoc.selectNodes("//book");
   while (oSelection.peekNode() != null) {
      oSelection.removeNext();
   }
   alert(xmlDoc.xml);
}
[Visual Basic]

Visual Basic Syntax

Set objXMLDOMNode = objXMLDOMSelection.removeNext

Example

Dim xmlDoc As New Msxml2.DOMDocument50
Dim oSelection As IXMLDOMSelection
xmlDoc.setProperty "SelectionLanguage", "XPath"
xmlDoc.async = False
xmlDoc.Load "books.xml"
If (xmlDoc.parseError.errorCode <> 0) Then
   Dim myErr
   Set myErr = xmlDoc.parseError
   MsgBox("You have error " & myErr.reason)
Else
   Set oSelection = xmlDoc.selectNodes("//book")
   While Not (oSelection.peekNode() Is Nothing)
      oSelection.removeNext
   Wend
   MsgBox xmlDoc.xml
End If
[C/C++]

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.

C/C++ 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.

To view reference information for Visual Basic, C/C++, or Script only, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Applies to: IXMLDOMSelection