NodeInsertBefore Method

The insertBefore() method of the Node interface inserts a node before a reference node as a child of a specified parent node.

If the given node already exists in the document, insertBefore() moves it from its current position to the new position. (That is, it will automatically be removed from its existing parent before appending it to the specified new parent.)

This means that a node cannot be in two locations of the document simultaneously.

Namespace: Aspose.Html.Dom
Assembly: Aspose.HTML (in Aspose.HTML.dll) Version: 22.1
Syntax
public Node InsertBefore(
	Node node,
	Node child
)

Parameters

node
Type: Aspose.Html.DomNode

The node to be inserted.

child
Type: Aspose.Html.DomNode

The node before which newNode is inserted. If this is null, then newNode is inserted at the end of node's child nodes.

Return Value

Type: Node

Returns the added child (unless newNode is a DocumentFragment, in which case the empty DocumentFragment is returned).

See Also