title: Parse HTML with jsoup and preserve original content
body: <p>I want to replace some elements in HTML files, keeping all the other content unchanged.</p>
  
  <pre><code>Document doc = Jsoup.parse("&lt;div id=title&gt;Old&lt;/div &gt;\n" +
          "&lt;p&gt;1&lt;p&gt;2\n" +
          "&lt;table&gt;&lt;tr&gt;&lt;td&gt;1&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;");
  doc.getElementById("title").text("New");
  System.out.println(doc.toString());
  </code></pre>
  
  <p>I expect to have the following output:</p>
  
  <pre><code>&lt;div id=title&gt;New&lt;/span&gt;&lt;/div &gt;
  &lt;p&gt;1&lt;p&gt;2
  &lt;table&gt;&lt;tr&gt;&lt;td&gt;1&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
  </code></pre>
  
  <p>Instead, I have:</p>
  
  <pre><code>&lt;html&gt;
   &lt;head&gt;&lt;/head&gt;
   &lt;body&gt;
    &lt;div id="title"&gt;New&lt;/div&gt;
    &lt;p&gt;1&lt;/p&gt;
    &lt;p&gt;2 &lt;/p&gt;
    &lt;table&gt;
     &lt;tbody&gt;
      &lt;tr&gt;
       &lt;td&gt;1&lt;/td&gt;
      &lt;/tr&gt;
     &lt;/tbody&gt;
    &lt;/table&gt;
   &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Jsoup added:</p>
  
  <ol>
  <li>closing p tags</li>
  <li>double-quotes to attribute values</li>
  <li>tbody</li>
  <li>html, head and body elements</li>
  </ol>
  
  <p>Can I serialise modified HTML back to original? <a href="http://jericho.htmlparser.net/">Jericho</a> does that but it doesn’t provide slick DOM manipulation methods as Jsoup does.</p>