title: Bash, Remove empty XML tags
body: <p>I need some help a couple of questions, using bash tools</p>
  
  <ol>
  <li>I want to remove empty xml tags from a file eg:</li>
  </ol>
  
  <pre class="lang-xml prettyprint-override"><code> &lt;CreateOfficeCode&gt;
        &lt;OperatorId&gt;ve&lt;/OperatorId&gt;
        &lt;OfficeCode&gt;1234&lt;/OfficeCode&gt;
        &lt;CountryCodeLength&gt;0&lt;/CountryCodeLength&gt;
        &lt;AreaCodeLength&gt;3&lt;/AreaCodeLength&gt;
        &lt;Attributes&gt;&lt;/Attributes&gt;
        &lt;ChargeArea&gt;&lt;/ChargeArea&gt;
   &lt;/CreateOfficeCode&gt;
  </code></pre>
  
  <p>to become:</p>
  
  <pre class="lang-xml prettyprint-override"><code> &lt;CreateOfficeCode&gt;
        &lt;OperatorId&gt;ve&lt;/OperatorId&gt;
        &lt;OfficeCode&gt;1234&lt;/OfficeCode&gt;
        &lt;CountryCodeLength&gt;0&lt;/CountryCodeLength&gt;
        &lt;AreaCodeLength&gt;3&lt;/AreaCodeLength&gt;
   &lt;/CreateOfficeCode&gt;
  </code></pre>
  
  <p>for this I have done so by this command</p>
  
  <pre><code>sed -i '/&gt;&lt;\//d' file
  </code></pre>
  
  <p>which is not so strict, its more like a trick, something more appropriate would be to find the <code>&lt;pattern&gt;&lt;/pattern&gt;</code> and remove it. Suggestion?</p>
  
  <ol start="2">
  <li>Second, how to go from:</li>
  </ol>
  
  <pre class="lang-xml prettyprint-override"><code> &lt;CreateOfficeGroup&gt;
         &lt;CreateOfficeName&gt;John&lt;/CreateOfficeName&gt;
         &lt;CreateOfficeCode&gt;
         &lt;/CreateOfficeCode&gt;
   &lt;/CreateOfficeGroup&gt;
  </code></pre>
  
  <p>to:</p>
  
  <pre class="lang-xml prettyprint-override"><code> &lt;CreateOfficeGroup&gt;
         &lt;CreateOfficeName&gt;John&lt;/CreateOfficeName&gt;
   &lt;/CreateOfficeGroup&gt;
  </code></pre>
  
  <ol start="3">
  <li>As a whole thing? from:</li>
  </ol>
  
  <pre class="lang-xml prettyprint-override"><code> &lt;CreateOfficeGroup&gt;
         &lt;CreateOfficeName&gt;John&lt;/CreateOfficeName&gt;
         &lt;CreateOfficeCode&gt;
              &lt;OperatorId&gt;ve&lt;/OperatorId&gt;
              &lt;OfficeCode&gt;1234&lt;/OfficeCode&gt;
              &lt;CountryCodeLength&gt;0&lt;/CountryCodeLength&gt;
              &lt;AreaCodeLength&gt;3&lt;/AreaCodeLength&gt;
              &lt;Attributes&gt;&lt;/Attributes&gt;
              &lt;ChargeArea&gt;&lt;/ChargeArea&gt;
         &lt;/CreateOfficeCode&gt;
         &lt;CreateOfficeSize&gt;
              &lt;Chairs&gt;&lt;/Chairs&gt;
              &lt;Tables&gt;&lt;/Tables&gt;
         &lt;/CreateOfficeSize&gt;
   &lt;/CreateOfficeGroup&gt;
  </code></pre>
  
  <p>to:</p>
  
  <pre class="lang-xml prettyprint-override"><code> &lt;CreateOfficeGroup&gt;
         &lt;CreateOfficeName&gt;John&lt;/CreateOfficeName&gt;
         &lt;CreateOfficeCode&gt;
              &lt;OperatorId&gt;ve&lt;/OperatorId&gt;
              &lt;OfficeCode&gt;1234&lt;/OfficeCode&gt;
              &lt;CountryCodeLength&gt;0&lt;/CountryCodeLength&gt;
              &lt;AreaCodeLength&gt;3&lt;/AreaCodeLength&gt;
         &lt;/CreateOfficeCode&gt;
   &lt;/CreateOfficeGroup&gt;
  </code></pre>
  
  <p>Can you answer the questions as individuals? Thank you very much!</p>