XML_APPEND_CLONE
Script function: Duplicates an XML element and attaches it to another element.
Syntax
XML_APPEND_CLONE (Reference element, Element)
| Syntax part | Description/format | 
|---|---|
| Reference element | Reference to the element to which the duplicated element should be attached. | 
| Element | Refers to the duplicated element. | 
                                            
                                            
                                        
| Return code | 
|---|
| Reference to the duplicated element. | 
The XML_APPEND_CLONE script element copies an element of the XML document that is open, and adds it to another element as a sub-element. The sub-element is always added as the last element.
All subordinate elements and values are taken into consideration during duplication.
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. The element 'SubChild3' is then copied and added to the element 'Child3' as a sub-element. All sub-elements of 'Child3' are output in the activation report for checking.
                                             
                                        
:SET &XMLDOCU#=XML_OPEN(DOCU,,"@Details")
                                            
                                            
:IF &XMLDOCU# <> ""
                                            
:SET &ELEMENT# = XML_SELECT_NODE(&XMLDOCU#,"Child2/SubChild3")
                                            
:SET &CHILD# = XML_SELECT_NODE(&XMLDOCU#,"Child3")
                                            
                                        
:SET &CLONECHILD# = XML_APPEND_CLONE(&CHILD#,&ELEMENT#)
                                            
                                            
: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#
                                        
Result in the activation log:
2013-08-14 14:19:17 – U0020408 Element: SubChild4
2013-08-14 14:19:17 – U0020408 Element: SubChild3
See also: