XML_APPEND_BEFORE

Script function: Moves an XML element in front of another element.

Syntax

XML_APPEND_BEFORE (Element, Reference element)

Syntax part

Description/format

Element

Reference to the element that should be moved.
Format: script literal or script variable

Reference element

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


Return code

Reference to the inserted element

The script element inserts a specific element in front of another element within the XML document that is open. This will move this element into the XML structure. The element that has been moved will then be located on the same level as the other element (reference element).

Important! Do not move the element to the top level. The reference element cannot be located on the top level.

Notes:

Example

The following example opens a structured Documentation tab and an XML document. The element 'SubChild1', which is located within 'Child1', is then moved in front of 'SubChild3' (in 'Child2').

All of the elements that are located within 'Child2' will then be output in the activation log.

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

:IF &XMLDOCU# <> ""
:SET &ELEMENT1# = XML_SELECT_NODE(&XMLDOCU#,"Child/SubChild1")
:SET &ELEMENT2# = XML_SELECT_NODE(&XMLDOCU#,"Child2/SubChild3")
:SET &NEW# = XML_APPEND_BEFORE(&ELEMENT1#,&ELEMENT2#)

:SET &ELEMENT# = XML_SELECT_NODE(&XMLDOCU#,"Child2")
:SET &ELEMENT# = XML_GET_FIRST_CHILD(&ELEMENT#)

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

:ENDIF

:XML_CLOSE &XMLDOCU#

The following lines are written in the report:

2013-08-14 13:32:27 – U0020408 Element: SubChild1
2013-08-14 13:32:27 – U0020408 Element: SubChild3

See also:

seealso

Script Functions for XML Elements