{
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
factory.setValidating(true);
DocumentBuilder builder = factory.newDocumentBuilder();
ErrorHandler errorHandler = new ErrorHandler() {
public void warning(org.xml.sax.SAXParseException e)
{
// System.err.println("Warning : " + e.getMessage());
}
public void error(org.xml.sax.SAXParseException e)
{
// System.err.println("Error : " + e.getMessage());
}
public void fatalError(org.xml.sax.SAXParseException e)
{
// System.err.println("FatalError : " + e.getMessage());
}
};
builder.setErrorHandler(errorHandler);
if (xml.substring(xml.length() - 3, xml.length()).equals("xml"))
{
returnDocument = builder.parse(new File(filePath + xml));
} else
{
InputStream in = new BufferedInputStream(new StringBufferInputStream(xml));
returnDocument = builder.parse(in);
}
} catch (IOException e)
{
logger.error("[getDocumentFromString] Exception thrown.", e);
} catch (ParserConfigurationException e)