title: How to insert elements with attributes to an XML file using XmlStarlet?
body: <h2>Source XML</h2>
  
  <pre><code>&lt;xml&gt;
      &lt;block&gt;
          &lt;el name="a"&gt;92346&lt;/el&gt;
          &lt;el name="b"&gt;lorem&lt;/el&gt;
      &lt;/block&gt;
      &lt;block&gt;
          &lt;el name="a"&gt;89753&lt;/el&gt;
          &lt;el name="b"&gt;ipsum&lt;/el&gt;
      &lt;/block&gt;
  &lt;/xml&gt;
  </code></pre>
  
  <h2>Object</h2>
  
  <p>I would like to insert an <code>&lt;el name="c"&gt;0&lt;/el&gt;</code> element in every <code>&lt;block&gt;</code> with a Linux shell script:</p>
  
  <pre><code>&lt;xml&gt;
      &lt;block&gt;
          &lt;el name="a"&gt;92346&lt;/el&gt;
          &lt;el name="b"&gt;lorem&lt;/el&gt;
          &lt;el name="c"&gt;0&lt;/el&gt;
      &lt;/block&gt;
      &lt;block&gt;
          &lt;el name="a"&gt;89753&lt;/el&gt;
          &lt;el name="b"&gt;ipsum&lt;/el&gt;
          &lt;el name="c"&gt;0&lt;/el&gt;
      &lt;/block&gt;
  &lt;/xml&gt;
  </code></pre>
  
  <p>I can append the elements using XmlStarlet:</p>
  
  <pre><code>xmlstarlet ed -a '/xml/block/el[@name="b"]' \
                --type 'elem' -n 'el' -v 0
  </code></pre>
  
  <h2>Questions</h2>
  
  <ol>
  <li>What is the XPath expression that selects every <code>&lt;el&gt;</code> element which
  doesn't have a <code>name</code> attribute?</li>
  <li>Can I append the elements and insert the attributes with a single
  <a href="http://xmlstar.sourceforge.net/doc/UG/ch04s03.html" rel="noreferrer"><code>xml ed</code></a> command?</li>
  </ol>