Read/Modify XML File Action

InstallAnywhere 2018

You can use the Read/Modify XML File action to modify an XML file on the target system.

Note • To perform complex modifications of an XML file, you can use multiple Read/Modify XML File actions. See Performing Complex XML File Modifications.

Properties Tab

The Properties tab of the Read/Modify XML File action customizer includes the following options:

Read/Modify XML File Customizer

Option

Description

Installed File

Select this option if you want the installer to modify a file the installer deploys on the target system. Click the Choose Target button to open the Read/Modify XML File dialog box and select the installed file you want the installer to modify.

Available only in the Install and Post-Install sequences.

Existing File

Select this option if you want the installer to modify a file that already exists on the target system. Enter the name of the file in the text box.

Read value

Select this option if you want the installer to read a value in the specified XML file. If you choose this option, the following additional options are listed:

Entire Tag—Select this option to read an entire XML tag in the file and specify the Tag in the text box.
Specific Attribute —Select this option to read a specific attribute of a tag in the XML file and specify that Tag and Attribute in the text boxes.
Variable to store value—Enter the name of an InstallAnywhere variable that you want to store the value that is read.

Note • The name of the Tag can be specified along with its occurrence using the format of tagname{occurrence#}, such as book{2}, where occurrence is a zero based occurrence of the tag book.

Replace value

Select this option if you want the installer to search for a specific value in the XML file and replace it with a replacement value. If you choose this option, the following additional options are listed:

Entire Tag—Select this option to search for an entire XML tag in the file and specify that Tag in the text box.
Specific Attribute —Select this option to search for a specific attribute of a tag in the XML file and specify that Tag and Attribute in the text boxes.
Replace by—Enter the replacement value for the specified Tag or Attribute.
Create backup—Select to create a backup of the original XML file.

Note • The name of the Tag can be specified along with its occurrence using the format of tagname{occurrence#}, such as book{2}, where occurrence is a zero based occurrence of the tag book.

Find occurrence of

Select this option if you want the installer to find a specific occurrence of a value of a tag or of a value of an attribute of a tag in the specified XML file. If you choose this option, the following additional options are listed:

A tag—Select this option to search the XML file for a specific occurrence of a value of a tag. Then enter the name of that tag and the value in the Tag and with value text boxes.
A tag with specific attribute / Tag / Attribute / with value—Select this option to search the XML file for a specific occurrence of a value of an attribute of a tag. Then enter the name of that tag, attribute, and the value in the Tag, Attribute, and with value text boxes.
Variable to store value—Enter the name of an InstallAnywhere variable that you want to store the value that is found

Note • The Tag specified should be an atomic/leaf node tag in the XML file.

Rules, Tags, and Rollback Tabs

For information on the other tabs on this customizer, see the following:

Rules—Use this tab to add rules to the selected action. For more information, see Assigning a Rule to an Action and Rules Reference.
Tags—Use this tab to add build configuration tags to the selected action. For more information, see Assigning Tags to Project Elements.
Rollback—Use this tab to specify rollback behavior for the selected action. For more information, see Configuring Installation Rollback Behavior.

Performing Complex XML File Modifications

To perform complex modifications, you can use multiple Read/Modify XML File actions. For example, suppose you had the following XML file:

Sample XML File

In this XML file, if you wanted to replace the value of the id attribute with a value of 300 instead of 296 for those book elements that have an author subelement with a value of Jones, you would use the following two Read/Modify XML File actions:

Use the first Read/Modify XML File action with the Find occurrence of option selected to find a book element with an author subelement with a value of Jones.

Use the second Read/Modify XML File action with the Replace value option selected to do the actual replace.

Note • If there are multiple nodes in the XML file that satisfy a given set of criteria specified in the customizer of the Read/Modify XML File action, then only the first node is returned by the result value.