XML_SET_ATTRIBUTE

Script function: Adds a new attribute to an XML element or changes an existing one.

Syntax

XML_SET_ATTRIBUTE (Element, Attribute, Value)

Syntax part

Description/format

Element

Reference to the element whose attribute will be changed or to which the new attribute will be added.
Format: script literal or script variable


Attribute

Name of the attribute proceeded by the '@' character
Format: script literal or script variable

Important! Always include the @ character before the name of the attribute. If you omit this character, a runtime error will occur.

Value Value of the attribute
Format: script literal or script variable


 

Return code

'0' – The attribute was successfully changed/added.

The script element changes an attribute of an element that is located in the XML document that is open. Specify a reference to the element, and the name and value of the attribute.

Notes:

Example

The following example opens a structured Documentation tab as an XML document and selects the 'Child' element. The new 'Attribute1' attribute will then be added to the element. If successfully added, the set attribute will then be read once more as a check and the value will be written to the activation log.

:SET &XMLDOCU#=XML_OPEN(DOCU,,"@Details")

:IF &XMLDOCU# <>
""
:SET &ELEMENT# = XML_SELECT_NODE(&XMLDOCU#,"Child")

:SET &RET# = XML_SET_ATTRIBUTE(&ELEMENT#,"@Attribute1","Value1")
:IF &RET# = 0

:SET &ATT# = XML_GET_ATTRIBUTE(&ELEMENT#,"@Attribute1")
:P &ATT#
:ENDIF

:ENDIF

:XML_CLOSE &XMLDOCU#

See also:

seealso

Script Functions for XML Elements