public class XMLParser extends Object
Modifier and Type | Method and Description |
---|---|
static DocumentBuilder |
createBuilderWithDefaultErrorHandler()
Creates a document-builder with default error-handling.
|
static Document |
createNewDocument()
Creates a new XML document.
|
static TransformerFactory |
createTransformerFactory()
Creates a
TransformerFactory that ignores any DTDs in the document and disables
external entities (to prevent XXE attacks). |
static Document |
parse(File file)
Parses a XML file to produce a
Document . |
public static DocumentBuilder createBuilderWithDefaultErrorHandler() throws ParserConfigurationException
ParserConfigurationException
- if a DocumentBuilder
cannot be created which
satisfies the configuration requested.public static TransformerFactory createTransformerFactory() throws TransformerConfigurationException
TransformerFactory
that ignores any DTDs in the document and disables
external entities (to prevent XXE attacks).DocumentBuilderFactory
TransformerConfigurationException
- if thrown by TransformerFactory.setFeature(java.lang.String, boolean)
.public static Document parse(File file) throws SAXException, IOException, ParserConfigurationException
Document
.file
- the XML file to parse.SAXException
- if any parse errors occur.IOException
- if any IO errors occur.ParserConfigurationException
- if a DocumentBuilder
cannot be created which
satisfies the configuration requested.public static Document createNewDocument() throws ParserConfigurationException
Document
ParserConfigurationException
- if a DocumentBuilder
cannot be created which
satisfies the configuration requested.Copyright © 2010–2023 Owen Feehan, ETH Zurich, University of Zurich, Hoffmann-La Roche. All rights reserved.