XML DOM appendChild() Method
Node object
Definition and Usage
The appendChild() method appends a new child node to the end of the node's list of child nodes.
This method returns the new child node.
Syntax
appendChild(newchild)
| Parameters | Description |
|---|---|
| newchild | The node to append. |
Example
The following code snippet uses loadXMLDoc() to load "books.xml" into xmlDoc, create a node (
Example
xmlDoc=loadXMLDoc("books.xml");
newel=xmlDoc.createElement("edition");
x=xmlDoc.getElementsByTagName("book")[0];
x.appendChild(newel);
document.write(x.getElementsByTagName("edition")[0].nodeName);
Output:
edition
Try it »
Try it
appendChild() - Append a child node to all
Node object