title: Creating an HTMLDocument from a String of HTML (in Java)
body: <p>I'm working on a method that takes a String of HTML and returns an analogous </p>
  
  <pre><code> javax.swing.text.html.HTMLDocument
  </code></pre>
  
  <p>What is the most efficient way of doing this?</p>
  
  <p>The way I'm currently doing this is to use a SAX parser to parse the HTML string.  I keep track of when I hit open tags (for example, &lt;i&gt;).  When I hit the corresponding close tag (for example, &lt;/i&gt;), I apply the italics style to the characters I've hit in between.</p>
  
  <p>This certainly works, but it's not fast enough.  Is there a faster way of doing this?</p>