code: private Document parseStringToDOM(String s, String encoding) {
      try {
        DocumentBuilderFactory factory = DocumentBuilderFactory
            .newInstance();
        factory.setValidating(false);
        InputStream is = new ByteArrayInputStream(s.getBytes(encoding));
        Document doc = factory.newDocumentBuilder().parse(is);
        return doc;
      } catch (SAXException e) {
        e.printStackTrace();
        System.out.println("Exception processing string.");
      } catch (ParserConfigurationException e) {
        e.printStackTrace();
        System.out.println("Exception processing string.");
      } catch (IOException e) {
        e.printStackTrace();
        System.out.println("Exception processing string.");
      }
      return null;
    }
docs: Parse a string to a DOM document.
  
  @param s
  A string containing an XML document.
  
  @return The DOM document if it can be parsed, or null otherwise.