ImportXML
- Last UpdatedOct 29, 2026
- 3 minute read
The function ImportXML is used to import Studio XML files into your project during run time.
|
Function |
Group |
Execution |
String Exp. |
Windows |
Windows Embedded |
IoT View |
Thin Clients |
Mobile Access |
|---|---|---|---|---|---|---|---|---|
|
ImportXML |
File |
Synchronous |
No |
Supported (Server Only, see "Notes") |
Not supported |
Not supported |
Not supported |
Not supported |
Syntax
ImportXML(strXMLFile,optStrDestFile,optNumFileType,optNumReplaceDuplicate)
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.
Note: Follow the conventions of the target platform for the file path and name, and separators. For example, a file path in Windows starts with a drive letter and uses backward slashes as separators (C:\path\to\file), while a file path in Linux starts at the root directory and uses forward slashes as separators (/path/to/file).
optStrDestFile
The new name of the project file, if any.
This parameter is optional; if no value is specified, 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 no value is specified, 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.scc would be duplicates.
|
Value |
Description |
|---|---|
|
0 |
Do not replace duplicate project file. |
|
1 |
Replace duplicate project file. |
This parameter is optional; if no value is specified, 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 (that is, 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 Edge HMI development 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.scc 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.scc if it does not already exist:
ImportXML("C:\Users\<user name>\Documents\AVEVA Edge2026 Projects\SMA_Project\Screen\Screen1.xml")
Look for Screen1.xml at the specified file path, and then import it to create Screen9.scc if it does not already exist:
ImportXML("C:\Users\<user name>\Documents\AVEVA Edge2026 Projects\SMA_Project\Screen\Screen1.xml","Screen9.scc")
Look for Screen1.xml at the specified file path, and then import it to replace Screen9.scc:
ImportXML("C:\Users\<user name>\Documents\AVEVA Edge2026 Projects\SMA_Project\Screen\Screen1.xml","Screen9.scc",0,1)