Here you can find the source of parseXML(InputStream in)
Parameter | Description |
---|---|
in | a parameter |
Parameter | Description |
---|---|
IOException | an exception |
public static Document parseXML(InputStream in) throws IOException
//package com.java2s; //License from project: Apache License import java.io.IOException; import java.io.InputStream; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; public class Main { /**//from w w w. java 2 s. c o m * parse XML document * @param in * @return * @throws IOException */ public static Document parseXML(InputStream in) throws IOException { Document document = null; DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); //factory.setValidating(true); //factory.setNamespaceAware(true); try { DocumentBuilder builder = factory.newDocumentBuilder(); //builder.setErrorHandler(new XmlErrorHandler()); //builder.setEntityResolver(new XmlEntityResolver()); document = builder.parse(in); // close input stream in.close(); } catch (Exception ex) { throw new IOException(ex.getMessage()); } return document; } }