Changing XML node values ​​from WiX

I want to be able to change the value of an XML node from WiX. The XML structure is as follows:

<settings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <setting name="setting1">
        <value xsi:type="xsd:boolean">false</value>
    </setting>
    <setting name="setting2">
        <value xsi:type="xsd:string">hello</value>
    </setting>
</settings>

I want to change the string value of parameter2 to something else. I'm trying to use XmlConfig, and code that doesn't work looks like this:

<util:XmlConfig Id='SetSetting2' File='[#defaultSettings.xml]'
                Action='create' Node='value'
                ElementPath="//settings/setting[\[]@name='setting2'[\]]/value"
                Name='value' Value="test"
                On='install' PreserveModifiedDate='yes'
                VerifyPath="//settings/setting[\[]@name='setting2'[\]]/value/"/>

But this makes the XML look like this:

<setting name="setting2">
    <value xsi:type="xsd:string" value="test"></value>
</setting>

How to make it look like the following?

<setting name="setting2">
    <value xsi:type="xsd:string">test</value>
</setting>
+3
source share
1 answer

Try to exclude the attribute Name. Like this:

<util:XmlConfig Id='SetSetting2' 
                File='[#defaultSettings.xml]'
                Action='create' 
                Node='value'
                ElementPath="//settings/setting[\[]@name='setting2'[\]]/@value"
                Value="test"
                On='install' 
                PreserveModifiedDate='yes'
                VerifyPath="//settings/setting[\[]@name='setting2'[\]]/@value/"/>

See also XmlConfig Element . For the attribute, Nameit says:

Without setting this attribute, it is necessary to set the value of the element text. Otherwise, the specified attribute name is specified.

+7
source

Source: https://habr.com/ru/post/1793045/


All Articles