The insertBefore() method inserts a new child node before an existing child node.
This method returns the new child node.
Parameter | Description |
---|---|
new_node | Required. The node to insert |
existing_node | Required. The existing node. The new node is inserted before this node. |
The following code fragment loads "books.xml" into xmlDoc using loadXMLDoc(), creates a new <book> node and inserts it before the last <book> element: