Action: CreateElement

Purpose: Creates a new Element Node and optionally appends it into its owner DOM.

If you don't attach the newly created node, you can attach it to its DOM tree at a later time using either the AppendChild or InsertBefore Action

You need to specify the TagName. For example, if you want to create the following Element node:

<div>

TagName = div

Note that M/DB:X will allow you to create Elements with prefixed TagNames, eg ewd:myTag, without performing any Schema validation or Namespace cross-checks. M/DB:X leaves such conformance and schema validation to be your responsibility. Whilst this means that M/DB:X can be used to generate invalid (though properly structured) XML that may not validate against other systems, the benefit is that creation and manipulation of the DOM is much simpler and less complex than in other more formal XML environments. Provided you understand how to maintain Schema conformance and proper namespace referencing, you'll find it very quick and easy to build and manipulate valid conformant XML documents with M/DB:X.

If you believe you absolutely need the rigour and formality of a full-blown XML database, then M/DB:X is probably not for you!

Action-specific name/value pairs:

Parameter Name Description
TagName The Element's TagName.
DocumentName or DocumentOID The Name or OID of the DOM in which you wish to create the new Node.
AppendTo (optional) The OID of the Node to which the newly-created Node will be appended as a Last Child. If not specified, the newly created Node will be left unattached in the Document.

Alternatively, the parameters above can be incorporated into a single JSON string and specified using the parameter name JSON, eg:

{TagName:"div",DocumentName:"example",AppendTo:"1-3"}

Example Request

Action=CreateElement
&DocumentName=example
&MDBAccessKeyId=[your access key id]
&Signature=[computed signature]
&SignatureMethod=HmacSHA256
&SignatureVersion=2
&TagName=div
&Timestamp=2009-06-14T13%3A19%3A41
&Version=2009-04-15
&db=mdbx

or:

Action=CreateElement
&JSON=%7BTagName%3A%22div%22%2CDocumentName%3A%22example%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

Example Response

XML

<?xml version='1.0'?>
<CreateElementResponse xmlns="http://mdbx.mgateway.com/doc/2009-06-05/">
   <CreateElementResult>
      <NodeOID>
         1-32
      </NodeOID>
      <NodeType>
         1
      </NodeType>
   </CreateElementResult>
</CreateElementResponse>

JSON (ie if OutputFormat=JSON specified in the Request)

{NodeOID:"1-32",NodeType:1}

The OID assigned to the newly-created Element Node was 1-32. Note that the NodeType (Element = 1) is also returned for information only.