0

I am using WIX to add an XML element in a file. When my util:XmlConfig element had a VerifyPath attribute like this:

VerifyPath="/configuration/App/add[@key='ApiURL']"

nothing happened. Now I've changed it to look like this (based on some other code I found elsewhere in our codebase):

VerifyPath="/configuration/App/add[\[]@key='ApiURL'[\]]"

And it is correctly adding the element. What is this escaping and why is it necessary?

sirdank
  • 3,351
  • 3
  • 25
  • 58

2 Answers2

1

I was trying to figure out the answer to the same question as you independantly and I found the clue to answer your question here. This StackOverflow answer led me to this document about Formatted types in Windows Installer.

I have copied the relevant text below, but in short "[\[]" is how you get a literal "[" character.

If a substring of the form [\x] is found, it is replaced by the character x , where x is one character, without any further processing. Only the first character after the backslash is kept; everything else is removed. For example, to include a literal left bracket ([), use [\[]. The text [\[]Bracket Text[\]] resolves to [Bracket Text].

1800 INFORMATION
  • 131,367
  • 29
  • 160
  • 239
0

If I correctly understand the XPath specification and how it worked for me in the Wix toolset, these characters indicate that work is to be done with the add attribute, inside which there is a value of key

<configuration>
    <App>
        <add key='ApiURL'/>
    </App>
</configuration>

But we need to look in this direction. I myself have not found the specifics.

  • I think you correctly understand the XPath specification which is accurate in the first example. The second example is not an XPath but is required for this code to function. It's the weird escaping that should break the XPath which I don't understand. – sirdank Nov 16 '17 at 18:19