code: public static @NotNull Element parseText(@NotNull String text, boolean xhtmlEntities) throws JDOMException {
  
      // add root element
      String xhtmlString =
          (xhtmlEntities ? "<!DOCTYPE root [" + XHTML_ENTITY_DEF + "]>" : "")
          + "<root>" + text + "</root>";
  
      try {
        SAXBuilder saxBuilder = new SAXBuilder();
  
        if (xhtmlEntities) {
          saxBuilder.setEntityResolver(XHtmlEntityResolver.getInstance());
        }
  
        Document doc = saxBuilder.build(new StringReader(xhtmlString));
        return doc.getRootElement();
      }
      catch (IOException ex) {
        throw new RuntimeException("Error parsing XHTML fragment.", ex);
      }
  
    }
docs: Parses XHTML text string. Adds a wrapping "root" element before parsing and returns this root element.
  @param text XHTML text string (root element not needed)
  @param xhtmlEntities If set to true, Resolving of XHtml entities in XHtml fragment is supported.
  @return Root element with parsed xhtml content
  @throws JDOMException Is thrown if the text could not be parsed as XHTML