Action: AddElementToDOM
Purpose: Quick Action for creating a new Element with its associated attributes and text and appending it to a specified Node.
The OID of the newly-created Element will be returned in the response
Action-specific name/value pairs:
Parameter Name | Description |
TagName | The TagName for the new Element that is to be created |
ParentOID | The OID of the Node that will be the new node's Parent Node. |
Attribute.[no].Name (optional*) |
You can add any number of attributes to the new Element. Each one is
distinguished by a unique number (no). You specify the attribute name of the noth attribute using this parameter. For example Attribute.1.Name=myAttribute |
Attribute.[no].Value (optional*) | You specify the value of the noth attribute using this parameter. For example Attribute.1.Value="1234" |
Text (optional) | Text to be added to the new Element. Text must be appropriately URL-encoded. |
AsFirstChild (optional) |
If present and set to true, this parameter instructs M/DB:X to add the
new tag as the new first child of the specified parent Node. By default, the new Element will otherwise be added as the new last child of the specified parent Node. |
* If one or more attributes are to be added, then there must be a matching Attribute.[no].Name and Attribute.[no].Value parameter for each attribute.
Alternatively, the parameters above can be incorporated into a single JSON string and specified using the parameter name JSON, eg:
{TagName:"myNewTag",Text:"Hello World",ParentOID:"1-3",Attributes:{myAttribute:1234,id:"x12"}}
Note that if you are specifying the new Element using JSON, the Attributes are simply defined as a sub-object named Attributes.
Example Request
Action=AddElementToDOM &Attribute.1.Name=myAttribute &Attribute.1.Value=1234 &Attribute.2.Name=id &Attribute.2.Value=x12 &DocumentName=myExample &MDBAccessKeyId=[your access key id] &ParentOID=1-3 &Signature=[computed signature] &SignatureMethod=HmacSHA256 &SignatureVersion=2 &TagName=myNewTag &Text=Hello%20World &Timestamp=2009-06-14T13%3A19%3A41 &Version=2009-04-15 &db=mdbx
or:
Action=AddElementToDOM &JSON=%7BTagName%3A%22myNewTag%22%2CText%3A%22Hello%20World%22%2C ParentOID%3A%221-3%22%2CAttributes%3A%7BmyAttribute%3A1234%2Cid%3A%22x12%22%7D%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 add the following tag as the new last child of the Node whose OID is 1-3:
<myNewTag id='x12' myAttribute='1234'>Hello World<myNewTag>
<?xml version='1.0'?> <AddElementToDOMResponse xmlns="http://mdbx.mgateway.com/doc/2009-06-05/"> <AddElementToDOMResult> <NodeOID> 1-28 </NodeOID> </AddElementToDOMResult> </AddElementToDOMResponse>
In this example, the new Element has been created with a NodeOID of 1-28.