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

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

Notes:

  • The XML structure will only be modified in the memory. The script element does not have an effect on the Documentation tab.
  • Use the XML_OPEN script function to open the XML document. For more information, see XML_OPEN.

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# = XML_GET_FIRST_CHILD(&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: