I have been trying to parameterise the SQL DB connection string used by nLog when it is defined in a web.config file of a web site being deployed via Release Management and  WebDeploy i.e. I wanted to select and edit the bit highlighted of my web.config file

<configuration>  
    <nlog xmlns="[http://www.nlog-project.org/schemas/NLog.xsd"](http://www.nlog-project.org/schemas/NLog.xsd") xmlns:xsi="[http://www.w3.org/2001/XMLSchema-instance"](http://www.w3.org/2001/XMLSchema-instance")\> 

    <targets async="true">  
      <target xsi:type="Database" name="SQL" dbProvider="System.Data.SqlClient" connectionString="Data Source=myserver;Database=mydb;Persist Security Info=True;Pooling=False" keepConnection="true" commandText="INSERT INTO \[Logs\](ID, TimeStamp, Message, Level, Logger, Details, Application, MachineName, Username) VALUES(newid(), getdate(), @message, @level, @logger, @exception, @application, @machineName, @username)">  

        <parameter layout="${message}" name="@message"></parameter>  
        …….  
 

The problem I had was that the xpath query I was using was not returning the nLog node because the nLog node has a namespace defined. This means we can’t just use a query in the form

<parameter name="NLogConnectionString" description="Description for NLogConnectionString" defaultvalue="\_\_NLogConnectionString\_\_" tags="">  
  <parameterentry kind="XmlFile" scope="\\web.config$" match="/configuration/nlog/targets/target\[@name='SQL'\]/@connectionString" />  
</parameter>

I needed to use

<parameter name="NLogConnectionString" description="Description for NLogConnectionString" defaultvalue="\_\_NLogConnectionString\_\_" tags="">  
  <parameterentry kind="XmlFile" scope="\\web.config$" match="/configuration/\*\[local-name() = 'nlog'\]/\*\[local-name() = 'targets'\]/\*\[local-name() = 'target' and @name='SQL'\]/@connectionString" />  
</parameter>

So more complex, but it does work. Hopefully this will save others the time I wasted working it out today