XML DOM removeChild() Method
Element Object
Definition and Usage
The removeChild() method deletes a child node.
This function returns the removed node if successful, or NULL if it fails.
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
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 »
Try it Demos
removeChild() - Remove the last child node from a node list
Element Object