Feedback

  • Contents
 

XML Insert Node

This XML tool appends the New Child node to Node, or inserts New Child before Insert Before in the child list of Node. The types of nodes allowed as New Child depend on the type of Node.

Node types not listed below may not be specified as Node:

Attribute

Allowed child node types: Text, Entity Reference, and Document Fragment.

Document

Allowed child node types: Comment, Processing Instruction, Element, Document Fragment.
If the New Child node is an Element and the document already has a document element (root element), the existing document element will be replaced (Insert Before is ignored).

Document Fragment

Allowed child node types: CDATA, Comment, Element, Text, Entity Reference, Processing Instruction, Document Fragment.

Element

CDATA, Comment, Element, Text, Attribute, Entity Reference, Processing Instruction, Document Fragment.

Notes: This tool allows adding attributes to an element, even though attributes are not considered actual children of element nodes. This is a simplification to keep the number of tools low. If the New Child node is an attribute, it is added to the element. If an attribute of the same name as the added attribute already exists, the existing attribute is replaced with the new node. Insert Before must be left undefined.

This tool may not only be used to add new nodes but also to move nodes and whole branches in a document or to move nodes or branches to a different document. The node parent and owning document will be adjusted as necessary. If you want to move nodes within a document or between documents, you don’t need to remove the node before inserting it in the new location.

Errors occurring while inserting the node will be attached to Node. Thus, you have to call XML Get Error Info with Node as argument.

Inputs

Node

Node to which to add the new child node (new parent of New Child).

New Child

Node to add to Node.

Insert Before

Optional. Child node before which to insert the new child. If not specified, node will be added to end of the child list.

Exit Paths

Success

This path is taken if the node was successfully inserted.

Failure

This path is taken if the operation fails.