I'm working on automating the configuration of several JBoss servers, which involves editing a substantial number of XML files.
I'd like to script all these changes as much as possible. But the "standard" tools (sed, grep et al) do not work well with XML. Without necessarily resorting to a higher-level language, how can I script e.g. the insertion of a given XML snipper after a given XML element in a certain file?
Say for instance that my jboss-log4j.xml looks like
<!-- ====================== -->
<!-- More Appender examples -->
<!-- ====================== -->
<!-- Buffer events and log them asynchronously -->
<appender name="ASYNC" class="org.apache.log4j.AsyncAppender">
<errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
<appender-ref ref="FILE"/>
<!--
<appender-ref ref="CONSOLE"/>
<appender-ref ref="SMTP"/>
-->
</appender>
and that I want to add a new appender-ref element. What's the easiest way to do that from a script?