title: Preventing jQuery from changing self-closing tags with custom XML
body: <p>I'm creating a browser plugin (bookmarklet) that exacts a large XML document embedded within the page's <code>&lt;textarea&gt;</code> element.  This is a custom XML language that includes a few self-closing tags (e.g., <code>&lt;custom-tag /&gt;</code>). I'm able to capture the XML document, wrap it in a jQuery object variable (e.g., <code>$(myXml)</code>), and easily manipulate the data. However, after I try inserting the manipulated XML document back in the page's <code>&lt;textarea&gt;</code> element, all the self-closing tags are changed into separate opening and closing tags.  Here's an example of what's happening:</p>
  
  <p>BEFORE:</p>
  
  <pre><code>&lt;outer-tag&gt;
      &lt;SELF-CLOSING-TAG foo="bar" /&gt;
      &lt;second-tag&gt;
          &lt;third-tag&gt;Some Value&lt;/third-tag&gt;
      &lt;/second-tag&gt;
  &lt;/outer-tag&gt;
  </code></pre>
  
  <p>AFTER jQUERY MANIPULATION:</p>
  
  <pre><code>&lt;outer-tag&gt;
      &lt;SELF-CLOSING-TAG foo="bar"&gt;
          &lt;second-tag&gt;
              &lt;third-tag&gt;Some Value&lt;/third-tag&gt;
          &lt;/second-tag&gt;
      &lt;/SELF-CLOSING-TAG&gt;
  &lt;/outer-tag&gt;
  </code></pre>
  
  <p>Is there any way I can prevent jQuery (or is it just JavaScript or the browser?) from turning these self-closing tags into opening and closing tags?  This latter way is invalid for the XML schema we're using.  If there's no way around that, are there any other hacks worth considering?</p>
  
  <p>UPDATE:
  Drejc's ideas pointed me in the right direction to solve this issue.  After his input, I got the additional advice on this additional <a href="https://stackoverflow.com/questions/8068431/how-to-use-javascript-to-loop-through-a-long-string-to-insert-a-new-string-after/8068766#8068766">S.O. post</a> and together this solved the problem.</p>