Code example for DocumentBuilder

Methods: newDocument

            parser = factory.newSAXParser();
            final DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory
            final DocumentBuilder docBuilder = docBuilderFactory
            doc = docBuilder.newDocument();
        } catch (final ParserConfigurationException e) {
            throw new RuntimeException(
                    "Can't create SAX parser / DOM builder.", e);
        final Stack<Element> elementStack = new Stack<Element>();
        final StringBuilder textBuffer = new StringBuilder();
        final DefaultHandler handler = new DefaultHandler()
            private Locator locator;
            public void setDocumentLocator(final Locator locator)
                this.locator = locator; // Save the locator, so that it can be