It's a bit difficult to give a specific answer without seeing your code; however, in the linked article the message.addChild() call adds a child node to the original message. To replace an existing node, would probably want to do something with message.setNode() instead.
For example, if you wanted to replace the ORC-1 field, you would do this:
message.setNode('ORC-1', 'New data');
Note that message.setNode() accepts an instance, so if you wanted to replace the second ORC-1 field, you would do this:
message.setNode('ORC-1', 'New data', 2);
Using that in a loop is simply a matter of replacing the '2' above with the variable that gets incremented in your loop (in the linked article, the variable is called i ).
Feel free to contact firstname.lastname@example.org if you'd like to take a look at your specific channel.