我希望能够从WiX更改XML节点值。 XML结构如下所示:
<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>
我想将setting2的字符串值更改为其他内容。我正在尝试使用XmlConfig
,而无效的代码如下所示:
<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/"/>
但是这会产生如下所示的XML:
<setting name="setting2">
<value xsi:type="xsd:string" value="test"></value>
</setting>
如何使其如下所示?
<setting name="setting2">
<value xsi:type="xsd:string">test</value>
</setting>
答案 0 :(得分:7)
尝试省略Name
属性。像这样:
<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/"/>
另请参阅 XmlConfig Element 。对于属性Name
,它说:
不设置此属性会导致设置元素的文本值。否则,这指定了设置的属性名称。