title: How can I add a new child element to the web element in my bootstrap.xml file using xmlstarlet?
body: <p>How can I add a new child element <code>&lt;app url=&quot;metrics&quot; war=&quot;metrics.war&quot;/&gt;</code> to the <code>web</code> element in the xml file below using xmlstarlet:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;yes&quot;?&gt;
  &lt;!--
    ~ Licensed to the Apache Software Foundation (ASF) under one or more
    ~ contributor license agreements. See the NOTICE file distributed with
    ~ this work for additional information regarding copyright ownership.
    ~ The ASF licenses this file to You under the Apache License, Version 2.0
    ~ (the &quot;License&quot;); you may not use this file except in compliance with
    ~ the License. You may obtain a copy of the License at
    ~
    ~     http://www.apache.org/licenses/LICENSE-2.0
    ~
    ~ Unless required by applicable law or agreed to in writing, software
    ~ distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
    ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    ~ See the License for the specific language governing permissions and
    ~ limitations under the License.
    --&gt;
  &lt;broker xmlns=&quot;http://activemq.org/schema&quot;&gt;
    &lt;jaas-security domain=&quot;activemq&quot;/&gt;
    &lt;!-- artemis.URI.instance is parsed from artemis.instance by the CLI startup.
          This is to avoid situations where you could have spaces or special characters on this URI --&gt;
    &lt;server configuration=&quot;file:/var/lib/./artemisBroker/etc//broker.xml&quot;/&gt;
    &lt;!-- The web server is only bound to localhost by default --&gt;
    &lt;web bind=&quot;http://0.0.0.0:8161&quot; path=&quot;web&quot;&gt;
      &lt;app url=&quot;activemq-branding&quot; war=&quot;activemq-branding.war&quot;/&gt;
      &lt;app url=&quot;artemis-plugin&quot; war=&quot;artemis-plugin.war&quot;/&gt;
      &lt;app url=&quot;console&quot; war=&quot;console.war&quot;/&gt;
    &lt;/web&gt;
  &lt;/broker&gt;
  </code></pre>
  <p>This is in a <code>docker</code> image, I pull <code>ActiveMQ</code> and do that setup, then I want to add a <a href="https://github.com/jbertram/artemis-prometheus-metrics-plugin" rel="nofollow noreferrer">Prometheus Metrics Plugin</a>. I copy the required <code>jar</code>/<code>war</code> files to the correct folders, but now I need to modify the <code>bootstrap.xml</code> to reference the war file.</p>
  <p>I can see in the <code>Dockerfile</code> that <code>xmlstartlet</code> has been used to modify the <code>bind</code> attribute like this:</p>
  <pre><code>RUN cd /var/lib/artemisBroker/etc &amp;&amp; \
    xmlstarlet ed -L -N amq=&quot;http://activemq.org/schema&quot; \
      -u &quot;/amq:broker/amq:web/@bind&quot; \
      -v &quot;http://0.0.0.0:8161&quot; bootstrap.xml
  </code></pre>
  <p>But I cannot figure out how to add a new element.<br />
  I found <a href="https://stackoverflow.com/questions/30348920/xmlstarlet-namespace-issue-cant-extract-node-value-from-xml">this question</a>, which helped clarify some things, but I'm still doing something wrong.<br />
  After some trial and error I came up with the following:</p>
  <pre><code>xmlstarlet ed -L -N amq=&quot;http://activemq.org/schema&quot;\
  -s &quot;amq:broker/amq:web&quot; \
  -t elem -n &quot;app&quot;  bootstrap.xml
  </code></pre>
  <p>Which seems to run fine, and adds an <code>&lt;app /&gt;</code> element, but I can't figure out how to add the attributes I want without overwriting the other <code>&lt;app /&gt;</code> elements in the file.<br />
  What am I doing wrong?</p>