XML_BEAUTIFY
Use the XML_BEAUTIFY script function to make an XML document easier to read by adding structure and formatting. Without this script function, all the information about the XML document is not formatted and written to a file in one line without a line break. Opening such a file with a text editor such as Notepad would result in unreadable information. This script function requires a reference to access an element of the related XML documentation. Use it with other XML script functions, and XML_BEAUTIFY will then structure the element, including its associated sub-elements and attributes.
Tip: XML_BEAUTIFY beautifies the XML document before it is written to an XML file with XML_PRINTINTOFILE. For more information, see XML_PRINTINTOFILE.
Syntax
XML_BEAUTIFY (Reference)
Script Function and Parameters
-
XML_BEAUTIFY
Structures and formats an XML document -
Reference
Reference to the XML document whose structure you want to format
Format: script literal or script variable
Tips:- You can use the reference returned by XML_OPEN to prepare and format the presentation of the whole XML document. For more information, see XML_OPEN.
- You can also use XML_BEAUTIFY together with a script function that takes position within the XML document to get a reference (handle). The following are examples of script elements you can use for this purpose:
Return Codes
-
0
The content of the XML document was successfully beautified
Examples
The following example edits the complete structure of the XML documentation to allow comfortable reading, and then writes the result to the Docu.xml file.
Note: To make the example 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 details, 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 elements Description and Objects including their attributes in 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: