Removes the specified child node from the list of children and returns it.
var objXMLDOMNode = oXMLDOMNode.removeChild(childNode);
An object. Returns the removed child node.
The following script example creates an IXMLDOMNode
object (currNode
), removes a child node from it, and displays the text of the removed node.
var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.5.0"); var root; var currNode; var oldChild; xmlDoc.async = false; xmlDoc.load("books.xml"); if (xmlDoc.parseError.errorCode <> 0) { var myErr = xmlDoc.parseError; alert("You have error " + myErr.reason); } else { root = xmlDoc.documentElement; currNode = root.childNodes.item(1); oldChild = currNode.removeChild(currNode.childNodes.item(1)); alert(oldChild.text); }
Set objXMLDOMNode = oXMLDOMNode.removeChild(childNode)
An object. Returns the removed child node.
The following Microsoft® Visual Basic® example creates an IXMLDOMNode
object (currNode
), removes a child node from it, and displays the text of the removed node.
Dim xmlDoc As New Msxml2.DOMDocument50 Dim root As IXMLDOMElement Dim currNode As IXMLDOMNode Dim oldChild As IXMLDOMNode 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 root = xmlDoc.documentElement Set currNode = root.childNodes.Item(1) Set oldChild = currNode.removeChild(currNode.childNodes.Item(1)) MsgBox oldChild.Text End If
HRESULT removeChild( IXMLDOMNode *childNode, IXMLDOMNode **outOldChild);
childNode
object is not removed.oldChild
parameter is not a child of this node, when the specified oldChild
is read-only and cannot be removed, or when oldChild
is Null.To view reference information for Visual Basic, C/C++, or Script only, click the Language Filter button in the upper-left corner of the page.
Applies to: IXMLDOMAttribute | IXMLDOMCDATASection | IXMLDOMCharacterData | IXMLDOMComment | DOMDocument | IXMLDOMDocumentFragment | IXMLDOMDocumentType | IXMLDOMElement | IXMLDOMEntity | IXMLDOMEntityReference | IXMLDOMNode | IXMLDOMNotation | IXMLDOMProcessingInstruction | IXMLDOMText