Add an attribute to an XML element

WTSupported in traditional Synergy on Windows
WNSupported in Synergy .NET on Windows
USupported on UNIX
VSupported on OpenVMS
status = %XML_ELEM_SETATTRIBUTE(element, attr_name, attr_value)

Return value


XML_SUCCESS if the attribute was set successfully.



The XML element instance for which an attribute is being set. (XML_ELEM_TYPE)


The name of the attribute to look for or set. The maximum length is 256 characters. (a)


The value of the attribute. The maximum length is 65,022 characters. (a)


%XML_ELEM_SETATTRIBUTE looks for an XML attribute by name. If it finds it, it updates the attribute’s value. If it cannot find the attribute, it adds a new attribute to the element’s attribute list using the specified name and value.

In the XML document, attributes are written in an element’s start tag after the tag name, beginning with the name of the attribute, followed by an equal sign (=) and a value for the attribute. For example, in

<structure name="mystruct" >

name = “mystruct” is the attribute and its value.

This function is defined as ^VAL.

See also

%XML_OPTION for information about escaping text when calling %XML_ELEM_SETATTRIBUTE.


xcall xml_elem_setAttribute(f1, "name", "id")
xcall xml_elem_setAttribute(f1, "type", "decimal")
xcall xml_elem_setAttribute(f1, "size", "4")

For a complete example, see Example of assembling XML.