Add attributes in a list 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_ADDATTRIBUTES(element, attr_list)

Return value


One of the following values:

XML_SUCCESS = The attributes are added successfully.

XML_FAIL = The attributes are not added successfully.



The XML element instance to which attributes will be added. (XML_ELEM_TYPE)


The attribute list instance that contains the attributes to add. (XML_ATTRLIST_TYPE)


%XML_ELEM_ADDATTRIBUTES adds each attribute in the specified list of attributes to the specified XML element. These attributes shall be appended to any existing element attributes.

This function is defined as ^VAL.


The example below adds two attributes to the first element of the root element.

    doc         ,XML_DOC_TYPE
    root        ,XML_ELEM_TYPE
    elem        ,XML_ELEM_TYPE
    elemlist    ,XML_ELEMLIST_TYPE
    attr1       ,XML_ATTR_TYPE
    attr2       ,XML_ATTR_TYPE
    attrlist    ,XML_ATTRLIST_TYPE
; Get the list of all elements of root, then locate first element
    root = %xml_doc_getroot(doc)
    elemlist = %xml_elem_children(root)
    elem = %xml_elemlist_item(elemlist, 1)
; Create new attributes, put them into a list, and add it to the element
    attr1 = %xml_attr_create()
    xcall xml_attr_setname(attr1, "Height")
    xcall xml_attr_setvalue(attr1, "43inches")
    attr2 = %xml_attr_create()
    xcall xml_attr_setname(attr2, "Weight")
    xcall xml_attr_setvalue(attr2, "18lbs")
    attrlist = %xml_attrlist_create()
    xcall xml_attrlist_add(attrlist, attr1)
    xcall xml_attrlist_add(attrlist, attr2)

    xcall xml_elem_addattributes(elem, attrlist)