Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change XML node values from WiX

Tags:

xml

wix

I want to be able to change an XML node value from WiX. The XML structure looks like this:

<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 setting2 to something else. I'm trying to use XmlConfig and the code that is not working 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 produces XML looking like this:

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

How do I make it look like the following?

<setting name="setting2">
    <value xsi:type="xsd:string">test</value>
</setting>
like image 419
Daniel Enetoft Avatar asked Jun 18 '26 10:06

Daniel Enetoft


1 Answers

Try omitting the Name attribute. 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 attribute Name it says:

Not setting this attribute causes the element's text value to be set. Otherwise this specified the attribute name that is set.

like image 180
alimbada Avatar answered Jun 21 '26 01:06

alimbada



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!