idclaar
idclaar

Reputation: 697

wix XmlConfig: is it possible to insert a new node in a particular position within a parent node

What I'm researching is whether the util:XmlConfig (or anything in the wix tool chest) can be used in such a way as to allow me to create on install a node at a particular position within its parent node. Here's an example:

...
<parentNode parentAttr1="parent attr1 value">
    <childNode childAttr1="child1 attr1 value" />
    <childNode childAttr1="child2 attr1 value" />
</parentNode>
...

I'd like to insert a new node between the two children, so that the result would be like this:

...
<parentNode parentAttr1="parent attr1 value">
    <childNode childAttr1="child1 attr1 value" />
    <childNode childAttr1="child3 attr1 value" />
    <childNode childAttr1="child2 attr1 value" />
</parentNode>
...

The code I have so far will place the new node as the last child of the parentNode and looks like this:

...
<util:XmlConfig
    Id="MY_ID"
    File="[PROPERTY_SQLRSPATH]ReportServer\rssrvpolicy.config"
    Action="create"
    On="install"
    ElementPath="//parentNode"
    Node="document"
    Sequence="1">
    <![CDATA[
        <childNode childAttr1="child3 attr1 value" />
]]>
</util:XmlConfig>
...

So, there it is in a nutshell. Any help on this is greatly appreciated!

EDIT: Another wrinkle on this topic would be given this structure:

...
<parentNode parentAttr1="parent attr1 value">
    <Abc anAttr="a value" />
    <Def someAttr="some value" />
</parentNode>
...

Is there any way to insert another sibling element between the current child elements so that the final structure looks like this??

...
<parentNode parentAttr1="parent attr1 value">
    <Abc anAttr="a value" />
    <Ghi YaAttr="yet another value" />
    <Def someAttr="some value" />
</parentNode>
...

Upvotes: 2

Views: 1049

Answers (1)

idclaar
idclaar

Reputation: 697

I've found no way to do this through wix tools. I've had to add a custom action that places the elements where I want them, and then have the installer add the details I want. Not what I'd consider great, but works for now, and uninstall works with this as well, though it leaves the empty elements in place.

Upvotes: 1

Related Questions