XML_APPEND_CLONE

Use the XML_APPEND_CLONE script function to copy an element of the open XML document and add it to another element as a sub-element. The sub-element is always added as the last element. All subordinate elements and values are considered during the duplication process.

Important! The XML structure is modified in the memory only. You do not see the changes of XML_APPEND_CLONE on the structured documentation page.

Tip: Use the XML_OPEN script function to open the XML document. For more information, see XML_OPEN.

Syntax

XML_APPEND_CLONE (Reference element, Element)

Script Function and Parameters

  • XML_APPEND_CLONE

    Duplicates an XML element and attaches it to another element
  • Reference element

    Reference to the element to which the duplicated element should be attached
    Format: script literal or script variable
  • Element

    Refers to the duplicated element
    Format: script literal or script variable

Return Code

This script function returns the reference to the duplicated element.

Example

The following example opens the @Details structured documentation page of the own object as an XML document. The 'Sub-Child-C' element is copied and added to the 'Child3' element as a sub-element.

Screenshot showing the @Details Structured Documentation page including a Child1 element with Sub-Child-A and Sub-Child-B, the Child2 element with Sub-Child-C, and the Child3 element with Sub-Child-D

:SET &XMLDOCU#=XML_OPEN(DOCU,,"@Details")

:IF &XMLDOCU# <> ""
:SET &ELEMENT# = XML_SELECT_NODE(&XMLDOCU#,"Child2/Sub-Child-C")
:SET &CHILD# = XML_SELECT_NODE(&XMLDOCU#,"Child3")

:SET &CLONECHILD# = XML_APPEND_CLONE(&CHILD#,&ELEMENT#)

:SET &ELEMENT# = XML_GET_FIRST_CHILD(&CHILD#)
:WHILE &ELEMENT# <> ""
: SET &NAME# = XML_GET_NODE_NAME(&ELEMENT#)
: P  'Element: &NAME#'
: SET &ELEMENT# = XML_GET_NEXTSIBLING(&ELEMENT#)
:ENDWHILE

:ENDIF



:XML_CLOSE &XMLDOCU#

The activation report shows all sub-elements of 'Child3’:

Screenshot showing the activation report that includes Sub-Child-C and Sub-Child-D as the children of the Child3 element.

See also: