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. |
Attribute | Name of the attribute proceeded by the '@' character Format: script literal or script variable |
Value | Value of the attribute Format: script literal or script variable |
Return code |
---|
'0' – The attribute was successfully changed/added. |
Notes
The script element changes an attribute of an element that is located in the XML document that is open (XML_OPEN). You need to specify a reference to the element and the name and value of the attribute. If the attribute you entered is not located, it will be added to the element again.
Please note that only the element stored in the memory will be changed. The Documentation tab is not affected by this.
A runtime error occurs if an '@' character is not entered before the name of the attribute.
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:
Script element | Description |
---|---|
XML_OPEN | Opens an XML document for processing. |
:XML_CLOSE | Closes an XML document. |
Script Element – Reading or Modifying Objects
Examples
Determining the Error Message and Number
About ScriptsAbout the Script
Script Elements – Alphabetical Listing
Script Elements – Ordered by Function