Here you can find the source of read(InputStream xml)
protected static Node read(InputStream xml) throws Exception
//package com.java2s; //License from project: LGPL import java.io.File; import java.io.InputStream; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Node; public class Main { protected static Node read(InputStream xml) throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); return builder.parse(xml).getDocumentElement(); }// w w w.java 2s . c o m protected static Node read(File xml) throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); return builder.parse(xml).getDocumentElement(); } }