Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

XML DOM removeChild() Method

XML DOM removeChild() Method


Node Object Reference Node object


Definition and Usage

The removeChild() method deletes a child node.

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

Syntax

elementNode.removeChild(node)

Parameters Description
node Required. Specifies the child node to delete.

Example

The following code snippet uses loadXMLDoc() to load "books.xml" load into xmlDoc, and delete the first node's child nodes:

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 »


Node Object Reference Node object