Action: SetAttribute

Purpose: Adds an attribute to a tag.

This Action may only be applied to Element Nodes. Attempting to use it with any other Node Type will return an error.

Action-specific name/value pairs:

Parameter Name Description
ElementOID The Element Node to which you wish to add the attribute
AttributeName The name of the Attribute you want to add
AttributeValue The value of the Attribute

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

{AttributeName:"onclick",AttributeValue:"runMyFunction()",ElementOID:"1-3"}

Example Request

Action=SetAttribute
&AttributeName=onclick
&AttributeValue=runMyFunction()
&ElementOID=1-3
&MDBAccessKeyId=[your access key id]
&Signature=[computed signature]
&SignatureMethod=HmacSHA256
&SignatureVersion=2
&Timestamp=2009-06-14T13%3A19%3A41
&Version=2009-04-15
&db=mdbx

or:

Action=SetAttribute
&JSON=%7BAttributeName%3A%22onclick%22%2CAttributeValue%3A%22runMyFunction()%22%2C
 ElementOID%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

Example Response

XML

In the example above, if the Element (1-3) was a <div> tag, the result of the Action would be to change the tag to <div onclick='runMyFunction()'>

Example Response

<?xml version='1.0'?>
<SetAttributeResponse xmlns="http://mdbx.mgateway.com/doc/2009-06-05/" />

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

{ok:true}