Automation Engine Script Guide > Ordered by Function > Read or Modify Objects > XML_APPEND_CLONE

XML_APPEND_CLONE

Script function: Duplicates an XML element and attaches it to another element.

Syntax

XML_APPEND_CLONE(Reference element, Element)

Syntax part

Description/format

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

Reference to the duplicated element.

Notes

The XML_APPEND_CLONE script element copies an element of the XML document that is open (see script element XML_OPEN) and adds it to another element as a sub-element. The sub-element is always added as the last element.

All subordinate elements and values are taken into consideration during duplication.

The script element only copies the XML structure that is stored in the memory. The Documentation tab is not changed.

Example

The following example opens the Documentation tab as an XML document. The element 'SubChild3' is then copied and added to the element 'Child3' as a sub-element. All sub-elements of 'Child3' are output in the activation report for checking.

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

:IF &XMLDOCU# <> ""
:SET &ELEMENT# = XML_SELECT_NODE(&XMLDOCU#,"Child2/SubChild3")
: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#

Result in the activation log:

2013-08-14 14:19:17 – U0020408 Element: SubChild4
2013-08-14 14:19:17 – U0020408 Element: SubChild3

 

See also:

Script element Description
XML_OPEN Opens an XML document for processing.
:XML_CLOSE Closes an XML document.