Purpose: Inserts a previously unattached Node (and its sub-tree of child Nodes if present) as the new Previous Sibling of a specified Node in a DOM. If the target Node is a First Child node, the inserted Node becomes the new First Child Node.
The OID of the Node that was inserted will be returned in the response. Note that this NodeOID will be the same as before it was attached.
Note that when nodes are created using the primitive Createtype Actions, they are associated with a Document but are not actually attached to the DOM tree. Until attached, such new Nodes will not appear if the OutputDOM Action is invoked, since this recursively lists all nodes attached under the DOM's DocumentNode.
Attempts to insert a Node that already has a ParentNode will return an error
A Node cannot be attached to a Node that belongs to a different Document. See the ImportNode and CopyNodes Actions if you are working between DOMs.
Action-specific name/value pairs:
|NodeOID||The OID of the currently unattached node that is to be appended into the DOM|
|BeforeNodeOID||The OID of the Node before which the unattached node will be inserted as a Previous Sibling.|
Alternatively, the parameters above can be incorporated into a single JSON string and specified using the parameter name JSON, eg:
Action=InsertBefore &BeforeNodeOID=1-3 &MDBAccessKeyId=[your access key id] &NodeOID=1-10 &Signature=[computed signature] &SignatureMethod=HmacSHA256 &SignatureVersion=2 &Timestamp=2009-06-14T13%3A19%3A41 &Version=2009-04-15 &db=mdbx
Action=InsertBefore &JSON=%7BNodeOID%3A%221-10%22%2CBeforeNodeOID%3A%221-3%22%7D &MDBAccessKeyId=[your access key id] &OutputFormat=JSON &Signature=[computed signature] &SignatureMethod=HmacSHA256 &SignatureVersion=2 &Timestamp=2009-06-14T13%3A19%3A41 &Version=2009-04-15 &db=mdbx
This request will insert Node 1-10 as the new First Sibling of the Node whose OID is 1-3. Any child nodes that are attached to node 1-10 will also now be present in the DOM as a result of this Action.
<?xml version='1.0'?> <InsertBeforeResponse xmlns="http://mdbx.mgateway.com/doc/2009-06-05/"> <InsertBeforeResult> <NodeOID> 1-10 </NodeOID> </InsertBeforeResult> </InsertBeforeResponse>