MSI Factory

XML Examples

Install XML Examples

Configure XML Examples

Install XML Examples

Example 1: Add a child element

An XML file located in C:\test.xml contains the following:

<root>
    <first>My Value</first>
</root>

Action: Create element
File:
C:\test.xml
Element path:
//root/first
Element/Attribute name:
first_child
Value:
Created Value
Sequence:
1
Permanent:
Unchecked

The above settings result in the following:

<root>
    <first>My Value<first_child>Created Value</first_child></first>
</root>

Example 2: Set an attribute's value

An XML file located in [ProgramFilesFolder]My Product\test.xml contains the following:

<root>
    <first>My Value</first>
</root>

Action: Set value
File:
[ProgramFilesFolder]My Product\test.xml
Element path:
//root/first
Element/Attribute name:
first_attrib
Value:
Attribute Value
Sequence:
1
Permanent:
Unchecked

The above settings result in the following:

<root>
    <first first_attrib="Attribute Value">My Value</first>
</root>

Note: If "Element/Attribute name" was left blank, "My Value" would have been replaced with "Attribute Value."

Example 3: Delete an attribute

An XML file located in C:\test.xml contains the following:

<root>
    <first first_attrib="Attribute Value">My Value</first>
</root>

Action: Delete value
File:
C:\test.xml
Element path:
//root/first
Element/Attribute name:
first_attrib
Value:
Sequence:
1
Permanent:
Unchecked

The above settings result in the following:

<root>
    <first>My Value</first>
</root>

Note: You cannot delete the <first> element, however you can delete it's value (My Value) by leaving "Element/Attribute name" blank.

Example 4: Add a series of elements

 An XML file located in C:\test.xml contains the following:

<root>
    <first>My Value</first>
</root>

Action: Create element
File:
C:\test.xml
Element path:
//root
Element/Attribute name:
second
Value:
Sequence:
1
Permanent:
Unchecked

Action: Create element
File:
C:\test.xml
Element path:
//root/second
Element/Attribute name:
second_child
Value:
Sequence:
2
Permanent:
Unchecked

Action: Create element
File:
C:\test.xml
Element path:
//root/second/second_child
Element/Attribute name:
cn
Value:
Value
Sequence:
3
Permanent:
Unchecked

The above actions result in the following:

<root>
    <first>My Value</first>
    <second>
        <second_child>
            <cn>Value</cn>
        </second_child>
    </second>
</root>

Configure XML Examples

Example 1: Create an element

An XML file located in C:\test.xml contains the following:

<root>
    <first>My Value</first>
</root>

Action: Create
Node:
Element
File:
C:\test.xml
Element path:
//root/first
Element/Attribute name:
first_child
Value:
Value
Verify path:
Timing:
Install
Sequence:
1

The above settings result in the following:

<root>
    <first>My Value<first_child>Value</first_child></first>
</root>

Example 2: Delete a value

An XML file located in [ProgramFilesFolder]My Product\test.xml contains the following:

<root>
    <first>My Value<first_child>Value</first_child></first>
</root>

Action: Delete
Node:
Value
File:
[ProgramFilesFolder]My Product\test.xml
Element path:
//root/first/first_child
Element/Attribute name:
Value:
Verify path:
//root/first/first_child
Timing:
Install
Sequence:
1

The above settings result in the following:

<root>
    <first>My Value<first_child></first_child></first>
</root>

Example 3: Delete an element

An XML file located in C:\test.xml contains the following:

<root>
    <first>My Value<first_child></first_child></first>
</root>

Action: Delete
Node:
Element
File:
C:\test.xml
Element path:
//root/first
Element/Attribute name:
first_child
Value:
Verify path:
//root/first/first_child
Timing:
Install
Sequence:
1

The above settings result in the following:

<root>
    <first>My Value</first>
</root>

Example 4: Create a value

An XML file located in C:\test.xml contains the following:

<root>
    <first>My Value</first>
</root>

Action: Create
Node:
Value
File:
C:\test.xml
Element path:
//root/first
Element/Attribute name:
Attribute
Value:
AttributeValue
Verify path:
//root/first
Timing:
Install
Sequence:
1

The above settings result in the following:

<root>
    <first Attribute="AttributeValue">My Value</first>
</root>

Example 5: Create a value on install, and delete a value on uninstall

An XML file located in C:\test.xml contains the following:

<root>
    <first>My Value</first>
</root>

Action: Create
Node:
Value
File:
C:\test.xml
Element path:
//root/first
Element/Attribute name:
Attribute
Value:
AttributeValue
Verify path:
//root/first
Timing:
Install
Sequence:
1

Action: Delete
Node:
Value
File:
C:\test.xml
Element path:
//root/first
Element/Attribute name:
Attribute
Value:

Verify path:
//root/first
Timing:
Uninstall
Sequence:
1

After the install, the result is:

<root>
    <first Attribute="AttributeValue">My Value</first>
</root>

After the uninstall, the result is:

<root>
    <first>My Value</first>
</root>

More Information

WiX Help File: XmlConfig Element

WiX Help File: XmlFile Element