%XML_ELEMLIST_INSERT

Insert an XML element 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_ELEMLIST_INSERT(elem_list, element, index)

Return value

status

One of the following values:

XML_SUCCESS = The element is inserted successfully.

XML_FAIL = The element is not inserted successfully.

Arguments

elem_list

The XML element list instance in which to insert the element. (XML_ELEMLIST_TYPE)

element

The XML element instance to insert. (XML_ELEM_TYPE)

index

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

Discussion

%XML_ELEMLIST_INSERT inserts the specified element before the specified index position in an XML element list.

This function is defined as ^VAL.

Examples

The following example inserts an element into the root element’s element list.

    doc         ,XML_DOC_TYPE
    root        ,XML_ELEM_TYPE
    elem1       ,XML_ELEM_TYPE
    elemlist    ,XML_ELEMLIST_TYPE
    count       ,i4
; Get a list of the children of root 
    root = %xml_doc_getroot(doc)
    elemlist = %xml_elem_children(root)
    count = %xml_elemlist_count(elemlist)  ;Get the number of elements
; Insert the new element in front of the last element
    elem1 = %xml_elem_create()
    xcall xml_elem_setname(elem1, "FolgersCoffee")
    xcall xml_elem_setAttribute(elem1, "grind", "finegrind")

    xcall xml_elemlist_insert(elemlist, elem1, count)