OK, either my questions are getting easier or I’m starting to get the hang of this.  I figured out that I need to escape the brackets and now it works fine.

My follow-up question is how do I check an XML file to see if an element already exists?

 

If the appSettings element is already there this I don’t need to create it.  However, the XmlFile Wix element is used from creating or updating elements…not for querying them.

__________

Doug Watts

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Douglas Watts
Sent: Monday, October 09, 2006 5:02 PM
To: wix-users@lists.sourceforge.net
Subject: [WiX-users] WiX XML Issue

 

I am trying to use the XmlFile element to modify the MACHINE.CONFIG file.  I need to add application settings for my app.  I need to add settings such that the config file ends up as follows:

<appSettings>

    <add key="MyKey1" value="key 1 value" />

    <add key="MyKey2" value="key 2 value" />

  </appSettings>

 

First I create an “add” element.  Next, I want to set the element’s attributes as shown above.  However, when I try to set the second “add” element I end up changing the first and adding an empty second “add” element.  I tried specifying the first element (ElementPath='//configuration/appSettings/add[1]') with no luck; I tried the last element (ElementPath='//configuration/appSettings/add[last()]') with no luck. 

 

I have tried the following:

 

<Component Id="MachineConfigComponent" Guid="00000000-0000-0000-0000-000000000000" >

   <XmlFile Id='XmlSettings1'

            File='[FRAMEWORKINSTALLPATH]v1.1.4322\CONFIG\Machine.Config'

            Action='' Name='appSettings' ElementPath='//configuration'

            Sequence='1' />

 

   <XmlFile Id='XmlSettings2'

            File='[FRAMEWORKINSTALLPATH]v1.1.4322\CONFIG\Machine.Config'

            Action='' Name='add' ElementPath='//configuration/appSettings'

            Sequence='2' />

   <XmlFile Id='XmlSettings3'

            File='[FRAMEWORKINSTALLPATH]v1.1.4322\CONFIG\Machine.Config'

            Action='' Name='key' Value='MyKey1'

            ElementPath='//configuration/appSettings/add'

            Sequence='3' />

   <XmlFile Id='XmlSettings4'

            File='[FRAMEWORKINSTALLPATH]v1.1.4322\CONFIG\Machine.Config'

            Action='' Name='value' Value='key 1 value'

            ElementPath='//configuration/appSettings/add'

            Sequence='4' />

 

   <XmlFile Id='XmlSettings5'

            File='[FRAMEWORKINSTALLPATH]v1.1.4322\CONFIG\Machine.Config'

            Action='' Name='add' ElementPath='//configuration/appSettings'

            Sequence='5' />

   <XmlFile Id='XmlSettings6'

            File='[FRAMEWORKINSTALLPATH]v1.1.4322\CONFIG\Machine.Config'

            Action='' Name='key' Value='MyKey2'

            ElementPath='//configuration/appSettings/add[1]'

            Sequence='6' />

   <XmlFile Id='XmlSettings7'

            File='[FRAMEWORKINSTALLPATH]v1.1.4322\CONFIG\Machine.Config'

            Action='' Name='value' Value='key 2 value'

            ElementPath='//configuration/appSettings/add[1]' Sequence='7' />

</Component>

 

Does anyone know how to add elements and set their attributes when the element names are the same?

 

__________

Doug Watts

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

Reply via email to