当前位置 : 主页 > 网页制作 > xml >

从WiX更改XML节点值

来源:互联网 收集:自由互联 发布时间:2021-06-13
我希望能够从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 /
我希望能够从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>
尝试省略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,它说:

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

网友评论