I have the following XML in my web config and I would like to select an attribute for removal using web.config transforms, but I would like to select the element for removal based on the value of one of the child elements.
My web.config is something like this:
<configuration>
<sitecore>
<scheduling>
<agent type="Sitecore.Tasks.DatabaseAgent">
<param desc="database">core</param>
</agent>
<agent type="Sitecore.Tasks.DatabaseAgent">
<param desc="database">master</param>
</agent>
</scheduling>
</sitecore>
</configuration>
I have tried the following to try to select the second agent element for deletion based on the child element <param desc="database">master</param>
but with no success.
<configuration>
<sitecore>
<scheduling>
<!-- Attempt 1 -->
<agent type="Sitecore.Tasks.DatabaseAgent"
xdt:Transform="Remove"
xdt:Locator="XPath(configuration/sitecore/scheduling/agent/param[text()='master'])"/>
<!-- Attempt 2 -->
<agent type="Sitecore.Tasks.DatabaseAgent"
xdt:Transform="Remove">
<param desc="database"
xdt:Locator="XPath([text()='master'])"/>
</agent>
</scheduling>
</sitecore>
</configuration>
Just use Sitecores own config patcher. This will remove your setting:
For more information, look here:
http://intothecore.cassidy.dk/2009/05/working-with-webconfig-include-files-in.html http://www.thescrewballdivision.com/playing-with-sitecore-include-files
As answered in this question the
xdt:Locator
attribute needs to use theCondition
syntax. So the required selector is:Just add
/..
onto the end, that should do it..e.g.