So, last month I posted an article about changing XML values in memory. All very useful for when you have to manage configuration in the modern world of “build once, deploy many.” I’m not going to repeat myself on what I said on that blog, it’s all very interesting to for people who like that sort of thing, go and have a read.

Yet it only focused on a somewhat simple example, and so as XML can get very complex, I wanted to show a similar method to find elements where they are not unique by making use of attributes that are.

Let’s say we have some xml that lists sandwiches from my favourite bakery in London. This bakery is very French, or “très français” as the French would say, if they were to say such a thing.

So let’s pretend we live in a world where we want to replace the fillings list for  given sandwich with the French translation. Using the attribute “Include” we can create a variable with this exact same name with the updated value and apply.


One thing I want to discuss today which I didn’t touch upon was the “$missingVariables” part. I have been doing configuration management long enough to know that one of the most common mistakes is to omit a  variable that will update a value of a file that needs to be configured for a given environment. So what this part of the script achieves is making sure that when we do have part of an xml file that needs values updated, we do not forget to do this part. This needs to be part of a deployment script and can be implemented pretty much anywhere.