Automation Engine Script Guide > Ordered by Function > Read or Modify Objects > XML_TO_STRING

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.

Notes

The script element converts the XML structure of a specified element to a character string, which is then stored in a script variable, for example, and can be processed further. The reference to the corresponding XML element should also be specified. All sub-elements of the specified element will also be taken into consideration.

The reference has to reference an XML element and can be determined using an XML script element (such as XML_GET_FIRST_CHILD or XML_SELECT_NODE.

It is also possible to enter the complete XML document, which is captured using XML_OPEN.

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:

Script element Description
XML_OPEN Opens an XML document for processing.
:XML_CLOSE Closes an XML document.