XML_APPEND_ELEMENT

Script function: Attaches an existing XML element to another element.

Syntax

XML_APPEND_ELEMENT (Reference element, Element)

Syntax part

Description/format

Reference element

Reference to the element to which the element will be added.
Format: script literal or script variable

Element

Reference to the element in front of which the other element will be inserted.
Format: script literal or script variable


 

Return code

Reference to the attached element

Notes

The script function attaches a specific element of the XML document that is open (XML_OPEN) to another element as a sub-element. This moves the element.

The change to the XML structure only takes place in the memory. The Documentation tab is not affected by the script element.

Example

The following example opens the structured Documentation tab as an XML document. In addition, the element 'SubChild3', which is located within 'Child2', is then attached to the first element of the XML structure (Child1).

All of the sub-elements that are located within 'Child1' will then be logged in the activation report.

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

:IF &XMLDOCU# <>
""
:SET &FIRST# = XML_GET_FIRST_CHILD(&XMLDOCU#)
:SET &TOAPPEND# = XML_SELECT_NODE(&XMLDOCU#,"Child2/SubChild3")

:SET &CLONECHILD# = XML_APPEND_ELEMENT(&FIRST#,&TOAPPEND#)

:SET &ELEMENT# = &FIRST#

: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 13:32:27 – U0020408 Element: SubChild1
2013-08-14 13:32:27 – U0020408 Element: SubChild2
2013-08-14 13:32:27 – U0020408 Element: SubChild3

See also:

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