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.  | 
                                            
| 
                                                     Name  | 
                                                
                                                     Name of the new sub-element  | 
                                            
| 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:
- 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 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: