15 lines
521 B
Text
15 lines
521 B
Text
|
|
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
|
// Impose restrictions on the complexity of the DTD.
|
|
factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
|
|
|
|
// Turn on validation.
|
|
// This step can be omitted if validation is not desired.
|
|
factory.setValidating(true);
|
|
|
|
// Parse the document.
|
|
DocumentBuilder builder = factory.newDocumentBuilder();
|
|
builder.setEntityResolver(new NoEntityResolver());
|
|
builder.setErrorHandler(new Errors());
|
|
Document document = builder.parse(inputStream);
|
|
|