code: public static Document stringToDoc(String str) throws IOException {
          if (StringUtils.isNotEmpty(str)) {
              try (Reader reader = new StringReader(str)) {
                  DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
                  Document doc = db.parse(new InputSource(reader));
  
                  return doc;
              } catch (Exception ex) {
                  log.debug("String: {}", str);
                  throw new IOException(String.format("Error converting from string to doc %s", ex.getMessage()));
              }
          } else {
              throw new IOException("Error - could not convert empty string to doc");
          }
      }
docs: Converts string representation of XML into Document
  
  @param str
  String representation of XML
  @return DOM object
  @throws IOException
  I/O exception