XML_TO_STRING
Use the XML_TO_STRING script function to retrieve and convert the XML structure of a specific element (handle) to a string. You can use the string that XML_TO_STRING returns for further processing by storing it in a script variable.
Syntax
XML_TO_STRING (Reference)
Parameters
| Parameter | Description | Format |
|---|---|---|
| Reference |
Reference to the corresponding XML element. All sub-elements of the specified element are considered. Tips: References or handles let you identify and edit a position within the XML document. You can use the following script functions to retrieve handles:
|
Script literal or script variable |
Return Codes
This script function returns the XML of the defined reference as a string.
Examples
The following example opens the @Details structured documentation page as an XML document. The complete XML document is then converted to a string and stored in a script variable. In this script variable, you replace the 'test' string with 'prod'. Once the old XML document is closed, the new XML in the script variable is reopened as an XML document, and its elements (first-level elements) are written to the activation log in a loop:
: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: