Hi Mike,
Option 1 did not work - I got a message saying: 
"Failed to find snippet node //SnippetCollection//Language/SnippetDir[last()]"

With option 2 (which was very promising and such a simple solution for me) I 
get this error in the MSI log. The setup just rolls back immediately:
"ExecXmlConfig:  Error 0x8007006e: Failed to load value as document."

Note: for option 2, I do not have any square brackets or properties that need 
to be escaped. I even tried it with a very simple one line XML.

Thanks!
Uma-





-----Original Message-----
From: Michael Turner [mailto:mcturner...@gmail.com] 
Sent: Wednesday, March 26, 2014 9:16 AM
To: wix-users@lists.sourceforge.net
Subject: Re: [WiX-users] Help with adding new elements using XMLConfig

Uma,

First of all, I don't think you can insert XML before a given node using 
XmlConfig; you can only append a new child to a given parent node.
(http://stackoverflow.com/q/8224918)

Also, there are two nodes that match your XPath expression, and XmlConfig only 
uses the first match.  Since you know that the node you have just added will 
always be the last one (due to the append behavior), you should try this XPath 
for your 1002 expression instead:

ElementPath="//SnippetCollection//Language/SnippetDir[\[]last()[\]]"

Notice that you must escape the square brackets per 
http://msdn.microsoft.com/library/aa368609.aspx

I am not certain whether the last() function actually works on XmlConfig, but 
this should get you closer.  If that does not work, then you can try this 
instead:

      <util:XmlConfig On="install" Action="create" 
Id="CreateSnippetDir" Node="document" File="<Path 
to Xml>\snippetsindex.xml"
ElementPath="//SnippetCollection//Language"
      xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
         
<![CDATA[<SnippetDir><OnOff>Off</OnOff><!-- More Stuff 
--></SnippetDir>]]>
      </util:XmlConfig>

If you use this, it can replace both of your XmlConfig elements, since it 
combines them into a single operation.  Note the Node="document", which lets 
you specify the XML content to insert, as inner-text of the XmlConfig node. 
I am not sure whether the Node="document" construct treats the inner-text as a 
"Formatted String" (http://msdn.microsoft.com/library/aa368609.aspx) or not, so 
if your "More Stuff" contains any square brackets or [PropertyName] 
expressions, you may need to experiment to see how it behaves.

Regards,
Mike


uharano wrote
> I want to add the highlighted lines with my setup:
> <SnippetCollection>
>     
> <Language Lang="CSharp" Guid="{694DD9B6-B865-4C5B-AD85-86356E9C88DC}">
>         &lt;!-- BEGIN HIGHLIGHT --&gt;
>         
> <SnippetDir>
>             
> <OnOff>
> Off
> </OnOff>
> &lt;!-More stuff --&gt;
>         
> </SnippetDir>
>         &lt;!-- END HIGHLIGHT --&gt;
>         
> <SnippetDir>
>             
> <OnOff>
> On
> </OnOff>
>             
> <Installed>
> true
> </Installed>
>             
> <Locale>
> 1033
> </Locale>
>             
> <DirPath>
> %InstallRoot%\VC#\Snippets\%LCID%\Visual C#\ </DirPath>
>             
> <LocalizedName>
> Visual C#
> </LocalizedName>
>         
> </SnippetDir>
>     
> </Language>
> </SnippetCollection>
> In Wix these are my lines of code:
>       &lt;util:XmlConfig On=&quot;install&quot; 
> Action=&quot;create&quot; Id=&quot;CreateSnippetDir&quot; 
> Node=&quot;element&quot; File=&quot;&lt;Path to Xml&gt;\snippetsindex.xml"
> ElementPath="//SnippetCollection//Language" Sequence="1001"
>       xmlns:util="http://schemas.microsoft.com/wix/UtilExtension";
> Name="SnippetDir"  />
>       &lt;util:XmlConfig On=&quot;install&quot; 
> Action=&quot;create&quot; Id=&quot;CreateOnOff&quot; 
> Node=&quot;element&quot; File=&quot;&lt;Path to 
> Xml&gt;\snippetsindex.xml\snippetsindex.xml"
> ElementPath="//SnippetCollection//Language/SnippetDir" Sequence="1002"
>       xmlns:util="http://schemas.microsoft.com/wix/UtilExtension";
> Name="OnOff" Value="off" />





--
View this message in context: 
http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Help-with-adding-new-elements-using-XMLConfig-tp7593764p7593776.html
Sent from the wix-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book "Graph Databases" is the 
definitive new guide to graph databases and their applications. Written by 
three acclaimed leaders in the field, this first edition is now available. 
Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users


------------------------------------------------------------------------------
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

Reply via email to