ImportXML

The function ImportXML is used to import Studio XML files into your project during run time.

Function Group Execution Windows Embedded Thin Client Mobile Access
ImportXML File Synchronous Supported (see “Notes” below) Not supported Not supported Not supported

Syntax

  ImportXML(strXMLFile,optStrDestFile,optNumFileType,optNumReplaceDuplicate)  
Web Studio Help cs2ffunctions file importxml.xml d408609e112 ImportXML

strXMLFile
The file path and name of the XML file to be imported. If you specify only a file name with no path, the runtime will automatically look in the Screen and Web sub-folders of your project folder.
optStrDestFile
The new name of the project file, if any.

This parameter is optional; if you do not specify a tag or value, then the default value is "screen".

optNumFileType
A numeric flag indicating the type of Studio XML file to be imported. At this time, only Studio XML Screen files are supported.
Value Description
0 Studio XML Screen file

This parameter is optional; if you do not specify a tag or value, then the default value is 0.

optNumReplaceDuplicate
A numeric flag indicating whether the imported XML file should replace an existing project file of the same name. For example, Objects.xml and Objects.scr would be duplicates.
Value Description
0 Do not replace duplicate project file.
1 Replace duplicate project file.

This parameter is optional; if you do not specify a tag or value, then the default value is 0.

Returned value

This function returns one of the following possible values:
Value Description
-2 Invalid license; this function is not available in Demo Mode.
-1 Cannot execute this function on the project client (i.e., Viewer). Execute the function on the project server.
0 Function executed successfully.
1 Invalid number of parameters.
2 Invalid parameter data type.
3 Cannot replace duplicate file.
4 Failed to load import module. (ImportXML does not work when your project is running as a Windows service. For more information, see Run a project as a Windows service.)
5 File type (optNumFileType) not supported.
6 Failed to create destination file.
7 Internal error.
8 Failed to save imported screen.
9 Failed to retrieve screen file.
10 Internal XML file error.

Notes

This function can be executed only on the project server, where the InduSoft Web Studio develoment environment must be installed and running with at least a Runtime license. You can use the functions StartTask, EndTask, and IsTaskRunning with the parameter "Studio" to programmatically control the development environment.

For more information about Studio XML Screen files and how they are created, see Import a Studio XML Screen.

Examples

Look for Screen1.xml in the Screen and Web sub-folders, and then import it to create Screen1.scr if it does not already exist:
  ImportXML("Screen1.xml")  
Look for Screen1.xml at the specified file path, and then import it to create Screen1.scr if it does not already exist:
  ImportXML("C:UsersusernameDocumentsInduSoft Web Studio v7.1 ProjectsSMA_ProjectScreenScreen1.xml")  
Look for Screen1.xml at the specified file path, and then import it to create Screen9.scr if it does not already exist:
  ImportXML("C:UsersusernameDocumentsInduSoft Web Studio v7.1 ProjectsSMA_ProjectScreenScreen1.xml","Screen9.scr")  
Look for Screen1.xml at the specified file path, and then import it to replace Screen9.scr:
  ImportXML("C:UsersusernameDocumentsInduSoft Web Studio v7.1 ProjectsSMA_ProjectScreenScreen1.xml","Screen9.scr",0,1)  

ImportXML