class DOMParserUtil {

    public static Document getDocument(String xml) throws ParserConfigurationException, IOException, SAXException {
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        factory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
        factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
        DocumentBuilder dBuilder = factory.newDocumentBuilder();
        try (InputStream inputStream = new ByteArrayInputStream(xml.getBytes())) {
            return dBuilder.parse(inputStream);
        }
    }

    private  DOMParserUtil();

}