XML DOM insertNode() methode
Definitie en gebruik
De insertNode() methode voegt een knoop in aan het begin van het bereik in.
syntaxis:
insertNode(newNode)
parameter
parameter | Description |
---|---|
newNode | de knopen die moeten worden ingevoegd in het document. |
goor
als newNode is een Attr-, Document-, Entity- of Notation-node, deze methode zal een INVALID_NODE_TYPE_ERR-code gooien RangeException-exception.
onder de volgende voorwaarden zal deze methode ook een DOMException-exception met de volgende code gooien:
- HIERARCHY_REQUEST_ERR - Het beginpunt van het bereik mag geen subnodes bevatten, het mag ook geen subnodes van de gespecificeerde type hebben of newNode is an ancestor node of the node (or the node itself).
- NO_MODIFICATION_ALLOWED_ERR - The node containing the starting point of the range (or its ancestor node) is read-only.
- WRONG_DOCUMENT_ERR - newNode is different from the document to which the range belongs.
Description
This method will insert the specified node (and all its child nodes) at the beginning of the document range. When this method returns, the current range will include the newly inserted nodes. If newNode has already been part of the document, it will be deleted from the current position and then reinserted at the starting point of the range. If newNode is DocumentFragment node, then the node inserted is not itself, but its child nodes, inserted in order at the starting point of the range.
If the node containing the starting point of the current range is a Text node, it will be split into two adjacent nodes before the insertion operation. If newNode is a Text node, after inserting it into the document, it will not merge with any adjacent Text nodes. To merge adjacent nodes, you need to call Node.normalize() method.