%XML_ATTRLIST_INSERT

Insert an attribute at a specific position in a list

WSupported on Windows
USupported on Unix
VSupported on OpenVMS
NSupported in Synergy .NET
status = %XML_ATTRLIST_INSERT(attr_list, attr, index)

Return value

status

One of the following values:

XML_SUCCESS = The attribute is inserted successfully.

XML_FAIL = The attribute is not inserted successfully.

Arguments

attr_list

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

attr

The XML attribute instance to insert. (XML_ATTR_TYPE)

index

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

Discussion

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

This function is defined as ^VAL.

Examples

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)