XML_APPEND_CHILD

Script function: Adds a new sub-element to an XML element.

Syntax

XML_APPEND_CHILD (Element, Name, Value)

Syntax part

Description/format

Element

Reference to the element to which a new sub-element will be added.
Format: script literal or script variable

Name

Name of the new sub-element
Format: script literal or script variable

Value Value of the new sub-element
Format: script literal or script variable


 

Return code

Reference to the newly inserted sub-element

The script element inserts a new sub-element before a specific element of the XML document that is open. A reference to the element to which the sub-element is allocated needs to be specified, as well as the name/value of the new sub-element. The sub-element is always added at the end.

Important! No spaces should appear in the name of the new sub-element.

Notes:

Example

The following example opens the Documentation tab as an XML document and the 'Child3' element to the new sub-element 'New_Child'. All of the sub-elements that are located within 'Child3' will then be output in the activation log.

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

:IF &XMLDOCU# <> ""
:SET &CHILD# = XML_SELECT_NODE(&XMLDOCU#,"Child3")
:SET &NEWCHILD# = XML_APPEND_CHILD(&CHILD#,"New_Child","Test")

: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#

This means that the following lines are written in the  Report:

2013-08-14 13:32:27 – U0020408 Element: SubChild4
2013-08-14 13:32:27 – U0020408 Element: New_Child

 

See also:

seealso

Script Functions for XML Elements