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 any queries.
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.
- 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.
Syntax
XML_PRINTINTOFILE (File, Reference)
Script Function and Parameters
-
XML_PRINTINTOFILE
Writes the structure of elements in an XML file -
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
Note: You must provide a reference, 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:
Return Code
-
0
The structure was successfully written to the file.
Example
The following example edits the complete structure of the documentation to allow for more comfortable reading. Then, the information is written 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 shows how you can print the elements 'Description' and 'Objects' 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: