Skip to main content
Version: 20 R7 BETA

DOM SET XML ATTRIBUTE

DOM SET XML ATTRIBUTE ( elementRef ; attribName ; attrValue {; attribName2 ; attrValue2 ; ... ; attribNameN ; attrValueN} )

ParameterTypeDescription
elementRefTextXML element reference
attribNameTextAttribute to set
attrValueText, Boolean, Integer, Real, Time, DateNew attribute value

Description

The DOM SET XML ATTRIBUTE command adds one or more attributes to the XML element whose reference is passed in the elementRef parameter. It also sets the value of each attribute defined.

Pass the attribute you want to set and its value respectively in the attrName and attrValue parameters (in the form of variables, fields or literal values). You can pass as many attribute/value pairs as you want.
The attrValue parameter can be of the text type or another type (Boolean, integer, real, date or time). If you pass a value other than text, 4D handles its conversion to text, according to the following principles:

TypeExample of converted value
Boolean"true" or "false"
Integer"123456"
Real"12.34" (the decimal separator is always ".")
Date"2006-12-04T00:00:00Z" (RFC 3339 standard)
Time"5233" (number of seconds)

Example

In the following XML source:

<Book>
   <Title>The Best Seller</Title>
</Book>

If the following code is executed:

 vAttrName:="Font"
 vAttrVal:="Verdana"
 DOM SET XML ATTRIBUTE(vElemRef;vAttrName;vAttrVal)

We get:

<Book>
   <Title Font=Verdana>The Best Seller</Title>
</Book>

System variables and sets

If the command has been executed correctly, the system variable OK is set to 1. Otherwise, it is set to 0 and an error is generated.

See also

DOM GET XML ATTRIBUTE BY INDEX
DOM GET XML ATTRIBUTE BY NAME
DOM REMOVE XML ATTRIBUTE
XML SET OPTIONS

Properties

Command number866
Thread safe
Modifies variablesOK