Search code examples
xmlxpathwixwindows-installerwix3

Adding XML nodes with similar names using WiX


We have a configuration file of the form:

<Container>
    <Item>
        <name>Text</name>
    </Item>
    <Item>
        <name>MoreText</name>
    <Item>
</Container>

and want to add more Item/Name nodes using XMLFile or XMLConfig. While I can add a new empty Item node, I can't select that node itself to add the required name subnode. I've tried using:

ElementPath="/Container/Item[\[]last()[\]]"

After creating the new Item node, but WiX fails to find it.

Have I gone completely off the wall?


Solution

  • Just guessing but the problem may be that the default selection language. IIRC, the old "XSLPattern" selection language is the default and does not support last(). XmlFile lets you set the language. Looks like an oversight on XmlConfig.