code: public static Document stringToDocument(String xml) {
          try {
              SAXBuilder sax = new SAXBuilder();
              return sax.build(new ByteArrayInputStream(xml.getBytes("UTF-8")));
          } catch (JDOMException e) {
              throw new IllegalArgumentException("Unable to parse xml", e);
          } catch (IOException e) {
              throw new IllegalArgumentException("Unable to parse xml", e);
          }
      }
docs: Convert xml to JDOM2 {@link Document}. Throws {@link IllegalArgumentException} in case of errors.