public static Document stringToDom(String xmlString,boolean useNamespaces) throws SAXException {
  DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
  factory.setNamespaceAware(useNamespaces);
  StringReader reader=new StringReader(xmlString);
  InputSource input=new InputSource(reader);
  DocumentBuilder builder;
  try {
    builder=factory.newDocumentBuilder();
  }
 catch (  ParserConfigurationException e) {
    log.fatal("### Error - this should never happen: " + e.getMessage());
    return null;
  }
  Document dom;
  try {
    dom=builder.parse(input);
  }
 catch (  IOException e) {
    log.fatal("### Error - this should never happen: " + e.getMessage());
    return null;
  }
  return dom;
}

public static Document stringToDom ( String xmlString , boolean useNamespaces ) throws SAXException { DocumentBuilderFactory factory = DocumentBuilderFactory . newInstance ( ) ; factory . setNamespaceAware ( useNamespaces ) ; StringReader reader = new StringReader ( xmlString ) ; InputSource input = new InputSource ( reader ) ; DocumentBuilder builder ; try { builder = factory . newDocumentBuilder ( ) ; } catch ( ParserConfigurationException e ) { log . fatal ( "### Error - this should never happen: " + e . getMessage ( ) ) ; return null ; } Document dom ; try { dom = builder . parse ( input ) ; } catch ( IOException e ) { log . fatal ( "### Error - this should never happen: " + e . getMessage ( ) ) ; return null ; } return dom ; }
converts a string to a dom . sometimes , you might prefer dom to soapelement .
