title: Preventing Jsoup.parse from removing the closing </img> tag
body: <p>I'm parsing a piece of html with Jsoup.parse.</p>
  
  <p>Everything else is great, but I'm supposed to parse this html later in pdf converter.</p>
  
  <p>For some reason the Jsoup.parse removes the closing  tag and the pdf-parser throws an exception about missing closing img tag.</p>
  
  <pre><code>Can't load the XML resource (using TRaX transformer). org.xml.sax.SAXParseException; 
  lineNumber: 115; columnNumber: 4; The element
  type "img" must be terminated by the matching end-tag "&lt;/img&gt;"
  </code></pre>
  
  <p>How to prevent Jsoup.parse from removing the closing img tag?</p>
  
  <p>For example this line:</p>
  
  <pre><code>&lt;img src="C:\path\to\image\image.png"&gt;&lt;/img&gt;
  </code></pre>
  
  <p>turns to:</p>
  
  <pre><code>&lt;img src="C:\path\to\image\image.png"&gt;
  </code></pre>
  
  <p>Same happens with:</p>
  
  <pre><code>&lt;img src="C:\path\to\image\image.png"/&gt;
  </code></pre>
  
  <p>Here's the code:</p>
  
  <pre><code>private void createPdf(File file, String content) throws IOException, DocumentException {
          OutputStream os = new FileOutputStream(file);
              content = tidyUpHTML(content);
              ITextRenderer renderer = new ITextRenderer();
              renderer.setDocumentFromString(content);
              renderer.layout();
              renderer.createPDF(os);
          os.close();
      }
  </code></pre>
  
  <p>Here's the tidyUpHTML-method that is called in above method:</p>
  
  <pre><code>private String tidyUpHTML(String html) {
      org.jsoup.nodes.Document doc = Jsoup.parse(html);
      doc.select("a").unwrap();
      String fixedTags = doc.toString().replace("&lt;br&gt;", "&lt;br /&gt;");
      fixedTags = fixedTags.replace("&lt;hr&gt;", "&lt;hr /&gt;");
      fixedTags = fixedTags.replaceAll("&amp;nbsp;","&amp;#160;");
      return fixedTags;
  }
  </code></pre>