Example usage for org.jdom2.input StAXStreamBuilder build

List of usage examples for org.jdom2.input StAXStreamBuilder build

Introduction

In this page you can find the example usage for org.jdom2.input StAXStreamBuilder build.

Prototype

public Document build(XMLStreamReader reader) throws JDOMException 

Source Link

Document

This builds a document from the supplied XMLStreamReader.

Usage

From source file:org.kdp.word.utils.JDOMUtils.java

License:Apache License

public static Document parse(JDOMFactory factory, File inputfile) {
    try {//from  ww w.  j  ava2  s  .  c  om
        XMLInputFactory inputFactory = XMLInputFactory.newInstance();
        XMLStreamReader reader = inputFactory.createXMLStreamReader(new FileInputStream(inputfile));
        StAXStreamBuilder staxBuilder = new StAXStreamBuilder();
        staxBuilder.setFactory(factory);
        return staxBuilder.build(reader);
    } catch (FileNotFoundException | XMLStreamException | JDOMException ex) {
        throw new IllegalStateException("Cannot parse XML: " + inputfile, ex);
    }
}