Java Utililty Methods XML Document Parse

List of utility methods to do XML Document Parse

Description

The list of methods to do XML Document Parse are organized into topic(s).

Method

Documentparse(final DocumentBuilder documentBuilder, final File pomFile)
parse
try {
    return documentBuilder.parse(pomFile);
} catch (final Exception e) {
    throw new IllegalStateException(e.getMessage(), e);
Documentparse(String document)
parse
return parse(new ByteArrayInputStream(document.getBytes()));
DocumentparseDocument(byte[] bytes)
parse Document
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
documentBuilderFactory.setNamespaceAware(true);
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
InputStream is = new ByteArrayInputStream(bytes);
try {
    return documentBuilder.parse(is);
} finally {
    is.close();
...
DocumentparseDocument(File f)
parse Document
InputStream stream = new FileInputStream(f);
Document doc = builder.parse(stream);
stream.close();
return doc;
DocumentparseDocument(File file)
Utility method for constructing a Document from an XML file.
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
return builder.parse(file);
DocumentparseDocument(InputSource is)
Parses the given InputSource into a Document .
DocumentBuilder builder = newDocumentBuilder();
try {
    return builder.parse(is);
} catch (IOException e) {
    throw new RuntimeException(e);
} catch (SAXException e) {
    if (e instanceof SAXParseException) {
        throw (SAXParseException) e;
...
DocumentparseDocument(InputStream documentXml)
Creates a new document object from the given input stream containing the document XML.
return parseDocument(documentXml, true);
DocumentparseDocument(InputStream in)
parse Document
try {
    return DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(in);
} catch (Exception e) {
    throw new RuntimeException(e);
DocumentparseDocument(InputStream is)
Parses the given input stream as XML and returns the corresponding DOM document.
getImplementation();
DOMImplementationLS implLS = (DOMImplementationLS) impl;
LSInput input = implLS.createLSInput();
input.setByteStream(is);
LSParser builder = implLS.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS, null);
DOMConfiguration config = builder.getDomConfig();
config.setParameter("comments", false);
config.setParameter("element-content-whitespace", false);
...
DocumentparseDocument(InputStream is)
parse Document
DocumentBuilder builder = getBuilder();
try {
    return builder.parse(is);
} finally {
    releaseBuilder(builder);