When using XMLParser of Groovy (and smiliar APIs) to change a text-node’s content in an XML, it will loose the overall structure while parsing the file and thus when written back to a file. I.e. the spaces change, comments are removed, dtd-references are stripped.
There exists an ANT library called XMLTask that allows to do simple replacements with the help of XPath and maintains the overall structure of the file. Is there some similar and easy-to-use API in Java, Groovy, Jython or friends that allows this?
Preferably Groovy, so it integrates well with Gradle.
You could just stick xmltask on the classpath, and use groovy’s AntBuilder. There’s an example of this here I believe