XML_PRINTINTOFILE

Use the XML_PRINTINTOFILE script function to write the structure of an element, including all sub-elements and corresponding attributes, into a specified XML file.

Important! Existing files are overwritten without prompting.

Tip:

  • The information is written to the file as a single line with no line breaks, which is unintelligible in a text editor such as Notepad. Use XML_BEAUTIFY first to format the file's content for easier reading. You can also open the file in a web browser, where the element structure is shown more clearly. For more information, see XML_BEAUTIFY.

  • You can pass the reference returned by XML_OPEN to format the whole XML document, or a handle obtained from a positioning script function to format a specific element. For more information, see XML_OPEN.

More information:

Syntax

XML_PRINTINTOFILE (File, Reference)

Parameters

Parameter Description Format
File Name and path of the XML file Script literal or script variable
Reference Reference to the element whose structure is to be written Script literal or script variable

Return Codes

Return Value Condition
0 The structure was successfully written to the file

Examples

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

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

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

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

:XML_CLOSE

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

:SET &XMLDOCU# = XML_OPEN (DOCU, "ON_CALL_SERVICES""@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: