title: Removing empty elements from xml with regex that matches a sequence twice
body: <p>I'm looking to remove empty elements from an XML file because the reader expects a value. It's not a nil <code>xsi:nil="true"</code> or element without content <code>&lt;Element /&gt;</code> <a href="https://stackoverflow.com/questions/2966056/deserialize-xml-with-empty-elements-in-c-sharp">Deserialize Xml with empty elements in C#</a>. But Element where the inner part is simply missing <code>&lt;Element&gt;&lt;/Element&gt;</code></p>
  
  <p>I've tried writing my own code for removing these elements, but my code is too slow and the files too large. The end of every item will also contain this pattern. So the following regex would remove valid xml:<br>
  <code>@"&lt;.*&gt;&lt;/*&gt;</code></p>
  
  <p>I need some sort of regex that makes sure the pattern of the two * are the same.</p>
  
  <p>So:</p>
  
  <pre><code>&lt;Item&gt;&lt;One&gt;1&lt;/One&gt;&lt;Two&gt;&lt;/Two&gt;&lt;Three&gt;3&lt;/Three&gt;&lt;/Item&gt;
  </code></pre>
  
  <p>Would change into:</p>
  
  <pre><code>&lt;Item&gt;&lt;One&gt;1&lt;/One&gt;&lt;Three&gt;3&lt;/Three&gt;&lt;/Item&gt;
  </code></pre>
  
  <p>So the fact that it's all one one line makes this harder because it means the end of the item is right after the end of Three, producing the pattern I'd like to look for.</p>
  
  <p>I don't have access to the original data that would allow recreating valid xml.</p>