code: private Element toElement(String xml) {
          DOMResult dom = new DOMResult();
          try {
              TransformerFactory.newInstance().newTransformer().transform(new StreamSource(new StringReader(xml)), dom);
          } catch (Exception e) {
              e.printStackTrace();
          }
          return ((Document) dom.getNode()).getDocumentElement();
      }
docs: To element.
  
  @param xml the xml
  @return the element