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.

Comments

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

A reference must be given to the script function so that it can access the element. This reference  is made available by script elements which can take position within the XML document, such as XML_GET_FIRST_CHILD, XML_GET_NEXTSIBLING or XML_SELECT_NODE. This script function outputs this element including its sub-elements and corresponding attributes in a file.

The reference returned by XML_OPEN can also be used to write the whole structure.

All information about the element's structure is written to the specified file in a line (without line break). If you open this file with a text editor such as notepad, the information given is unintelligible. Apply XML_BEAUTIFY before you use the script function to format the file's content and have it displayed in a more intelligible way. The file can also be displayed with the Microsoft Internet Explorer. Here, the element's structure is displayed clearly.

Please note that existing files will be overwritten without any queries.

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:

Script element Description

XML_BEAUTIFY

Beautifies the display of an element's structure

Script Elements - Read or Modify Objects

Structured Documentation

www.w3c.org/TR/xmlbase

About Scripts
Script Elements - Alphabetical Listing

Script Elements - Ordered by Function