Java XML Document Parse parseDocument(Reader reader)

Here you can find the source of parseDocument(Reader reader)

Description

parse Document

License

Apache License

Declaration

public static Document parseDocument(Reader reader) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.IOException;

import java.io.Reader;

import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.w3c.dom.Document;

import org.xml.sax.InputSource;
import org.xml.sax.SAXException;

public class Main {
    public static Document parseDocument(Reader reader) throws IOException {
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        factory.setNamespaceAware(true);
        try {/*w  w w .  j  a  v  a2s.co  m*/
            return factory.newDocumentBuilder().parse(new InputSource(reader));
        } catch (ParserConfigurationException | SAXException e) {
            throw new IOException(e);
        }
    }
}

Related

  1. parseDocument(InputStream is)
  2. parseDocument(InputStream is)
  3. parseDocument(InputStream is)
  4. parseDocument(InputStream is)
  5. parseDocument(Path xmlPath)
  6. parseDocument(String docText)
  7. parseDocument(String documentString)
  8. parseDocument(String documentString)
  9. parseDocument(String path)