Script function: Moves an XML element in front of another element.
XML_APPEND_BEFORE (Element, Reference element)
Syntax part |
Description/format |
---|---|
Element |
Reference to the element that should be moved. |
Reference element |
Reference to the element in front of which the element should be inserted. |
Return code |
---|
Reference to the inserted element |
The script element inserts a specific element in front of another element within the XML document that is open (see script element XML_OPEN). This will move this element into the XML structure. The element that has been moved will then be located on the same level as the other element (reference element).
Please note that the XML structure will only be modified in the memory. The script element does not have an effect on the Documentation tab.
The element in front of which the element has been moved should not be located on the top level.
The following example opens a structured Documentation tab and an XML document. The element 'SubChild1', which is located within 'Child1', is then moved in front of 'SubChild3' (in 'Child2').
All of the elements that are located within 'Child2' will then be output in the activation log.
:SET &XMLDOCU#=XML_OPEN(DOCU,,"@Details")
:IF &XMLDOCU# <> ""
:SET &ELEMENT1# = XML_SELECT_NODE(&XMLDOCU#,"Child/SubChild1")
:SET &ELEMENT2# = XML_SELECT_NODE(&XMLDOCU#,"Child2/SubChild3")
:SET &NEW# = XML_APPEND_BEFORE(&ELEMENT1#,&ELEMENT2#)
:SET &ELEMENT# = XML_SELECT_NODE(&XMLDOCU#,"Child2")
:SET &ELEMENT# = XML_GET_FIRST_CHILD(&ELEMENT#)
:WHILE &ELEMENT# <> ""
: SET &NAME# = XML_GET_NODE_NAME(&ELEMENT#)
: P 'Element: &NAME#'
: SET &ELEMENT# = XML_GET_NEXTSIBLING(&ELEMENT#)
:ENDWHILE
:ENDIF
:XML_CLOSE &XMLDOCU#
The following lines are written in the report:
2013-08-14 13:32:27 – U0020408 Element: SubChild1
2013-08-14 13:32:27 – U0020408 Element: SubChild3
See also:
Script element | Description |
---|---|
XML_OPEN | Opens an XML document for processing. |
:XML_CLOSE | Closes an XML document. |
Script Element – Reading or Modifying Objects
Examples
Determining the Error Message and Number
About the Script
Script Elements – Alphabetical Listing
Script Elements – Ordered by Function