XML DOM removeChild()Methods


Node object

Definition and Usage

The removeChild() method deletes child nodes.

If successful, this function returns the deleted node; if it fails, it returns NULL.

Syntax

elementNode.removeChild(node)

Parameter Description
node Required. Specifies the child node to be deleted.

Example

The following code snippet usesloadXMLDoc()put "books.xmlLoad into xmlDoc, and delete the child nodes of the first <book> node:

Example

xmlDoc=loadXMLDoc("books.xml");

y=xmlDoc.getElementsByTagName("book")[0];
x=xmlDoc.documentElement.removeChild(y);

document.write("Removed node: " + x.nodeName);

Output:

Node removed: book

Try it Yourself »

Node objectother extensions