code: public static Document asDocument(String html) throws IOException {
          DOMParser domParser = new DOMParser();
          try {
              domParser
                      .setProperty(
                              "http://cyberneko.org/html/properties/names/elems",
                              "match");
              domParser.setFeature("http://xml.org/sax/features/namespaces",
                      false);
              domParser.parse(new InputSource(new StringReader(html)));
          } catch (SAXException e) {
              throw new IOException("Error while reading HTML: " + html, e);
          }
          return domParser.getDocument();
      }
docs: transforms a string into a Document object. TODO This needs more optimizations. As it seems
  the getDocument is called way too much times causing a lot of parsing which is slow and not
  necessary.
  
  @param html the HTML string.
  @return The DOM Document version of the HTML string.
  @throws IOException if an IO failure occurs.