XML_APPEND_CHILD
Use the XML_APPEND_CHILD script function to insert a new sub-element before a specific element of the open XML document. 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.
Important!
- The XML structure is modified in the memory only. You do not see the changes of XML_APPEND_CHILD on the structured documentation page.
- Do not use blanks in the name of the new sub-element.
Tip: Use the XML_OPEN script function to open the XML document. For more information, see XML_OPEN.
Syntax
XML_APPEND_CHILD (Element, Name, Value)
Script Function and Parameters
-
XML_APPEND_CHILD
Adds a new sub-element to an XML element -
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
This script function returns the reference to the newly inserted sub-element.
Example
The following example opens the @Details structured documentation page of the own object as an XML document and adds the new 'Child3' element to the 'New_Child' sub-element.
: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#
The activation report shows all sub-elements of 'Child3' and the 'New_Child' element:
See also: