This flow is an example of using the collector node type which can be found here: https://www.npmjs.org/package/node-red-contrib-collector
After pressing the a, b and c inject buttons, the following XML is output in the debug tab:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<root>
<a>Value A</a>
<b>Value B</b>
<c>Value C</c>
</root>
Pressing the no b button causes the <b>Value B</b>
element to be removed again.