XML_BEAUTIFY

Use the XML_BEAUTIFY script function to make an XML document easier to read by adding structure and formatting. Without it, the XML document is written to a file as a single line with no line breaks, which is difficult to read in a text editor such as Notepad. The script function requires a reference to an element of the related XML document. Use it together with other XML script functions; XML_BEAUTIFY then structures that element, including its sub-elements and attributes.

Tip: XML_BEAUTIFY structures the document before it is written to a file with XML_PRINTINTOFILE. You can pass the reference returned by XML_OPEN to format the whole document, or a handle obtained from a script function that positions within the document to format a specific element.

More information:

Syntax

XML_BEAUTIFY (Reference)

Parameters

Parameter Description Format
Reference Reference to the XML document whose structure you want to format Script literal or script variable

Return Codes

Return Value Condition
0 The content of the XML document was successfully beautified

Examples

The following example formats the complete structure of the XML document for easier reading, and then writes the result to the Docu.xml file.

Note: For this example to work, the object you use with XML_OPEN requires a structured Documentation page called "@Details". Add it to the relevant object in the UC_OBJECT_DOCU variable. For more information, see UC_OBJECT_DOCU - Object Documentation.

:SET &XMLDOCU# = XML_OPEN (DOCU, "ON_CALL""@Details")

:SET &RET1# = XML_BEAUTIFY (&XMLDOCU#)

:SET &RET2# = XML_PRINTINTOFILE ("C:\AUTOMIC\XML_Documentation\Docu.xml"&XMLDOCU#)

:XML_CLOSE

The following example prints the Description and Objects elements, including their attributes, to a file.

:SET &XMLDOCU# = XML_OPEN (DOCU, "ON_CALL""@Details")

:SET &HND# = XML_GET_FIRST_CHILD (&XMLDOCU#)

:SET &RET1# = XML_BEAUTIFY (&HND#)

:SET &RET2# = XML_PRINTINTOFILE ("C:\AUTOMIC\XML_Documentation\Docu.xml"&HND#)

:XML_CLOSE

See also: