How do I modify a CDATA Node in WiX with the XmlFile element?

884 views Asked by At

I am trying to modify an XML configuration file with the following content:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <applicationSettings>
        <App.Properties.Settings>
            <setting name="FeedAddress" serializeAs="String">
                <value><![CDATA[http://feedaddress.tld]]></value>
            </setting>
        </App.Properties.Settings>
    </applicationSettings>
</configuration>

with this XmlFile element:

<util:XmlFile
    Id="SetFeedAddress"
    Action="setValue"
    ElementPath="//configuration/applicationSettings/App.Properties.Settings/setting[\[]@name='FeedAddress'[\]]/value"
    File="[INSTALLFOLDER]App.exe.config"
    SelectionLanguage="XPath"
    Value="{[FEEDADDRESS]}"
    Sequence="4"/>

But the outcome is that the CDATA tag is removed and replaced by the text. I want to preserve the CDATA tag. I guess there should be several solutions for this problem.

One solution I have tried is modifying the XmlFile element to include the CDATA Tag like this:

Value="&lt;![CDATA[{[FEEDADDRESS]}]]&gt;"

But to no avail. The extension throws an error in this case.

Then I tried adding dummy properties holding the CDATA tag like this:

<Property Id="CDATASTART"><![CDATA[<![CDATA[]]></Property>
<Property Id="CDATAMID"><![CDATA[]]]]></Property>
<Property Id="CDATAEND"><![CDATA[>]]></Property>

And then I added them to the Value:

Value="{[CDATASTART]}{[FEEDADDRESS]}{[CDATAMID]}{[CDATAEND]}"

But this results in the following string:

&lt;![CDATA[http://host.tld]]&gt;

Somehow the extension replaces the smaller than and greater than signs with their XML entities.

So I guess the best solution would be if I could select the inner text element of the CDATA element with an XPath expression and then modify that node. Is there a way to achieve this?

0

There are 0 answers