public static Document createDOM(String strXML) throws ParserConfigurationException, SAXException, IOException {
  DocumentBuilderFactory dbf=DocumentBuilderFactory.newInstance();
  dbf.setValidating(false);
  dbf.setIgnoringComments(false);
  dbf.setIgnoringElementContentWhitespace(true);
  dbf.setNamespaceAware(true);
  dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING,true);
  dbf.setFeature(DISALLOW_DOCTYPE_DECL,true);
  dbf.setFeature(EXTERNAL_GENERAL_ENTITIES,false);
  dbf.setFeature(EXTERNAL_PARAMETER_ENTITIES,false);
  dbf.setFeature(LOAD_EXTERNAL_DTD,false);
  DocumentBuilder db=null;
  db=dbf.newDocumentBuilder();
  db.setEntityResolver(new NullResolver());
  db.setErrorHandler(new SamlParserErrorHandler());
  InputSource sourceXML=new InputSource(new StringReader(strXML));
  Document xmlDoc=db.parse(sourceXML);
  return xmlDoc;
}

public static Document createDOM ( String strXML ) throws ParserConfigurationException , SAXException , IOException { DocumentBuilderFactory dbf = DocumentBuilderFactory . newInstance ( ) ; dbf . setValidating ( false ) ; dbf . setIgnoringComments ( false ) ; dbf . setIgnoringElementContentWhitespace ( true ) ; dbf . setNamespaceAware ( true ) ; dbf . setFeature ( XMLConstants . FEATURE_SECURE_PROCESSING , true ) ; dbf . setFeature ( DISALLOW_DOCTYPE_DECL , true ) ; dbf . setFeature ( EXTERNAL_GENERAL_ENTITIES , false ) ; dbf . setFeature ( EXTERNAL_PARAMETER_ENTITIES , false ) ; dbf . setFeature ( LOAD_EXTERNAL_DTD , false ) ; DocumentBuilder db = null ; db = dbf . newDocumentBuilder ( ) ; db . setEntityResolver ( new NullResolver ( ) ) ; db . setErrorHandler ( new SamlParserErrorHandler ( ) ) ; InputSource sourceXML = new InputSource ( new StringReader ( strXML ) ) ; Document xmlDoc = db . parse ( sourceXML ) ; return xmlDoc ; }
create dom from string .
