I'm using a trick that was mentioned in this related question to programmatically add elements to a Change Set using the Salesforce Metadata API. Basically, you treat the name of the Change Set as your package name (YourChangeSetName) in your package.xml when calling the deploy() endpoint of the API.
If you add files and related entries to the package.xml, you can add elements to the Change Set.
However, I have gotten stuck when trying to remove elements from the Change Set. I was hoping that I could do the same thing I'm already doing but supplement with a destructiveChanges.xml file.
Unfortunately, when I deploy() the destructiveChanges.xml as part of my zip file that I use to update the Change Set, not only are the elements removed from the Change Set but they are removed from the entire org.
Not at all desirable!
So here's the question: Have you ever used MDAPI deploy() to remove items from a package or Change Set without destroying them from the org completely? If so, how did you do it?
I know I'm doing some pretty edge case stuff here, so I don't expect a satisfactory answer but wanted to put this up in case someone can help, or at least as a warning to others.
P.S. It's important to mention that simply not including someting in the normal package.xml DOES NOT take it out of the Change Set. The package.xml is interpreted additively by the MDAPI and anything inside it is merged into the Change Set. In my code I take advantage of this by only building a package.xml that includes things the User added during this session.