I have some XML that looks something like this:
We change config values for our different build environments (e.g. dev, staging, production) using config transformations. I assume that config transforms probably won't work for you, but if it's a possibility, check out this answer which shows how to apply .Net config transforms to any XML file.
An alternative would be to use the FileUpdate build task from the MSBuild Community Tasks project. This task allows you to use regular expressions to find and replace content in a file. Here's an example:
Because you'd be passing TeamCity system properties into FileUpdate if you decide to go with the second option, take a look at this question to see how system properties can be referenced in an MSBuild script.