XML_PRINTINTOFILE

Script Function: Writes the structure of elements in an XML file

Syntax

XML_PRINTINTOFILE (File, Reference)

Syntax

Description/Format

File

Name and path of the XML file
Format: script literal or script variable

Reference

Reference to the element whose structure is to be given
Format: script literal or script variable


Return code

"0" - The structure was successfully written to the file.

The script function writes the structure of an element, including all sub-elements and corresponding attributes, into a specified XML file.

Important! Existing files are overwritten without any queries.

Note: You must provide a handle to the script function to access the element. Use a script function that takes position within the XML document to provide the handle. The following are examples of script elements that you can use for this purpose:

Tips:

  • The information is written to the specified file in a line, without line breaks. If you open this file with a text editor such as notepad, the information given is unintelligible. Use XML_BEAUTIFY before you use the script function to format the file's content and display it in a more intelligible way. For more information, see XML_BEAUTIFY. You can also use Microsoft Internet Explorer to display the file, where the element's structure is shown more clearly.
  • Use the reference returned by XML_OPEN to write the whole structure. For more information, see XML_OPEN.

Example

The complete structure of the documentation is edited to enable more comfortable reading, and then written to the file "Docu.xml".

: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 shows how the elements "Description" and "Objects" including their attributes may be output 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: