Change XML node values from 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:boolea开发者_StackOverflown">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>
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.
精彩评论