Groovy's XML processing has a few slightly inconsistent features and a small hole wrt replacing nodes.
The replaceNode(Closure) method for DOMCategory returns the last added node rather than the removed node (making it inconsistent with the built-in replaceChild method) and equivalent methods for general collections (e.g. remove for ArrayList).
Ditto for the corresponding method in XmlParser. Also, XmlParser lacks a replaceNode(Node) variant.