XML_TO_STRING

Script function: Returns the XML of a specific element as text.

Syntax

XML_TO_STRING (Reference)

Syntax part

Description/format

Reference

Reference to the element.
Format: script literal or script variable


 

Return code

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:

You can use string returned by XML_TO_STRING for further processing, for example by storing it in a script variable.

Example

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.

:SET &XMLDOCU#=XML_OPEN(DOCU,,"@Details")
:DEFINE &XMLSTRINGNEW#,string

:IF &XMLDOCU# <>
""
 

:SET &XMLSTRING# = XML_TO_STRING(&XMLDOCU#)
:SET &XMLSTRINGNEW# = STR_SUB(&XMLSTRING#,"test","prod")


:ENDIF
:XML_CLOSE &XMLDOCU#

:SET &XMLDOCU#=XML_OPEN(STRING,&XMLSTRINGNEW#)

: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#)
:ENDWHILE

See also:

seealso

Script Functions for XML Elements