Script function: Returns the XML of a specific element as text.
Reference to the element.
XML of the reference entered, as a character string.
The script element converts the XML structure of a specified element to a character string. Specify the reference (handle) to the corresponding XML element. All sub-elements of the specified element are taken into consideration.
Use the following script functions to provide handles:
Returns the very first handle, which refers to the root element
Use the handled returned by XML_OPEN to return the complete XML document
Returns the handle of a particular element
Returns the handle of the first sub-element of an element
You can use string returned by XML_TO_STRING for further processing, for example by storing it in a script variable.
The following example opens the structured Documentation tab as an XML document. The complete XML document will then be converted to a character string and this will be stored in a script variable. The character string 'test' will be changed to 'prod' in the script variable.
The new XML in the script variable will then be reopened as an XML document once the XML document has been closed and its elements have been written (on the first level) in a loop to the activation log.
:IF &XMLDOCU# <> ""
:SET &XMLSTRING# = XML_TO_STRING(&XMLDOCU#)
:SET &XMLSTRINGNEW# = STR_SUB(&XMLSTRING#,"test","prod")
:SET &ELEMENT# = XML_GET_FIRST_CHILD(&XMLDOCU#)
:WHILE &ELEMENT# <> ""
: SET &NAME# = XML_GET_NODE_NAME(&ELEMENT#)
: P 'Element: &NAME#'
: SET &ELEMENT# = XML_GET_NEXTSIBLING(&ELEMENT#)