Insert an attribute at a specific position in a list

WTSupported in traditional Synergy on Windows
WNSupported in Synergy .NET on Windows
USupported on UNIX
VSupported on OpenVMS
status = %XML_ATTRLIST_INSERT(attr_list, attr, index)

Return value


One of the following values:

XML_SUCCESS = The attribute is inserted successfully.

XML_FAIL = The attribute is not inserted successfully.



The destination XML attribute list instance in which to insert the attribute. (XML_ATTRLIST_TYPE)


The XML attribute instance to insert. (XML_ATTR_TYPE)


The index position at which to insert the attribute in the list (starting at 1). (n)


%XML_ATTRLIST_INSERT inserts the specified attribute before the specified index position in an XML attribute list.

This function is defined as ^VAL.


The example below inserts a new attribute into an attribute list.

    doc         ,XML_DOC_TYPE
    root        ,XML_ELEM_TYPE
    elem        ,XML_ELEM_TYPE
    attr1       ,XML_ATTR_TYPE
    attrlist    ,XML_ATTRLIST_TYPE
    children    ,XML_ELEMLIST_TYPE

; Create a list of the attributes of element MaxwellHouse
    root = %xml_doc_getroot(doc)
    children = %xml_elem_children(root)
    elem = %xml_elemlist_findtag(children, "MaxwellHouse")
    attrlist = %xml_elem_attributes(elem)
; Create a new attribute
    attr1 = %xml_attr_create()
    xcall xml_attr_setname(attr1, "grind")
    xcall xml_attr_setvalue(attr1, "coursegrind")
; Insert in front of first attribute
    xcall xml_attrlist_insert(attrlist, attr1, 1)