Deleting XML element with XmlConfig extension in WIX using XPath

前端 未结 1 528
余生分开走
余生分开走 2021-01-14 12:09

I\'m trying to use XmlFile extension to delete entries in a XML file, this one to be precise: < Element name=\"Somename\" attribute2=\"whatever\" provider-name=\"whatever

相关标签:
1条回答
  • 2021-01-14 12:42
    1. To delete XML Elements you need to make use of the XMLConfig Element

    2. The XMLFIile Element is used to update/delete attributes within an element:

      deleteValue - Deletes a value from the element specified in the ElementPath. If Name is specified, the attribute with that name is deleted. If Name is not specified, the text value of the element specified in the ElementPath is deleted. The Value attribute is ignored if deleteValue is the action specified.

    Since you have not mentioned the "Name" attribute it is trying to delete the text value. You dont have a text value in the ELEMENT and hence your file remains the same even after the edit.

    UPDATE: Updated answer with the WIX script

    <util:XmlConfig Id='SetXMlfiletest'
                  File='[#filename]'
                  Action='delete'
                  Node='element'
                  ElementPath="/Elements"
                  On='install'
                  PreserveModifiedDate='yes'
                  VerifyPath="/Elements/Element[\[]@name='Somename'[\]]"
                  Sequence="1"    />
    

    In the above script you need to update the "#filename" with the ID of your xml file.

    Hope this helps!

    0 讨论(0)
提交回复
热议问题