Question

How can an xml element's value be edited using XmlConfig in WiX 3.7?

I'd like to edit this:

<root>
  <ele1/>
<root>

to this:

<root>
  <ele1>aValue</ele1>
</root>

The documentation for the XmlConfig Name attribute includes: "Not setting this attribute causes the element's text value to be set." But I have found no combination of using or omitting this attribute which alters an existing element's value.

This example results in an exception (Error 0x80004005: failed to create child element):

<util:XmlConfig
  Id          = "X.File.10"
  ElementPath = "//root/ele1"
  Value       = "[A_VALUE]"
  Action      = "create"
  Node        = "element"
  On          = "install"
  File        = "[#F.File]"
  Sequence    = "10" />

Either omitting the Action attribute or using combinations of VerifyPath and/or Name prevent the error from occuring, but result in either no edits to the file or duplicating (not editing) the ele1 element.

Attempting to delete the element or the root before re-adding it results in no edits being made to the file.

Was it helpful?

Solution

Change the Node value to value from element.

  <util:XmlConfig
  Id          = "X.File.10"
  ElementPath = "//root/ele1"
  Value       = "[A_VALUE]"
  Action      = "create"
  Node        = "value"
  On          = "install"
  File        = "[#F.File]"
  Sequence    = "10" />
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top