Recently, I wrote about patching Sitecore instances for specific roles. During my research on how to do this, I was able to use a manner of Sitecore patching I had not previously known about. With a patch:instead, instead of targeting an attribute of the element you can actually target the contents of that element. (Thanks to @jammykam for that Stack Overflow post!)

Why is this useful?

Typically patch:instead is used to replace one value with another in the settings, but because of the matching capabilities of this syntax you can use this to patch:delete elements you couldn’t otherwise match against.

So, when you need to remove an element from the configurations that have multiple elements with no distinguishing characteristics, you can target the inner content instead to distinguish them.

Yummy Config example!

Below is a sample config file which can remove a <using> tag by targeting the text inside the using tag.

<?xml version="1.0"?>
<configuration xmlns:patch="" xmlns:set="">
        <!--Target based on text in the tag-->
        <using patch:instead="using[.='Sitecore.Social.Client.Wizards.AddNetworkAccount']">
          <patch:delete />

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s