How to import and edit an XML file

ImportantThe following article uses options that are available starting with the Enterprise edition and project type.

NoteThis How-To explains how to import and edit XML files into your installation project. If you need to simply create a new XML file you can use the XML Editor.

Suppose your application contains an XML file which stores user information like username, password, e-mail or SQL connection details. This situation is very frequent, for instance, with .NET applications which use the “web.config“ file to store this information.

Create the MSI dialog

First, you will have to create the MSI dialog that will capture the user input, i.e. the information you wish to store in the XML file. For this, you can take a look at our New Dialog tutorial. If you wish you could use a predefined dialog from Advanced Installer, for example “SQLConnectionDlg“.

Import and edit the XML file

After you have added the new dialog in the project, you will have to import your XML file and edit it so it stores the values entered by the user in the edit boxes.

First, you need to go to Files and Folders page in the folder you want to install the XML file in and use the import XML option to add it to the project. This option is available both on the toolbar and in the files pane context menu.

After you have imported the desired file, double click it and edit the nodes you wish. This file supports formatted values so you can add the names of the public properties attached to your edit controls in it. For example, you wish to store the password and username in your XML file. The edit controls have the PASSWORD_PROP and USERNAME_PROP public properties attached to them.

NotePlease note that the properties are written using uppercase letters, this is a fundamental requirement so the information is correctly passed from the user interface to the installation process and in the end written in the XML file.

Using the above mentioned properties you could write them in the XML file like this:

          Username=[USERNAME_PROP];Pass=[PASSWORD_PROP]
        

After editing the XML file from the Files and Folders page and saving the project, you are done and can build the project if all the other settings you need were done. When the user runs the installation package and enters the username and password in the edit boxes created on the new dialog, they will automatically be written in the XML file by the installation process.

To see a working example, please follow this video tutorial:

ImportantThe same thing can be accomplished using INI files. This example was for XML files because this type of file is usually required for import and editing.

To see a working example with INI files, please follow this video tutorial: