public static Node read ( InputStream inputStream ) throws XmlException { try { DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory . newInstance ( ) ; DocumentBuilder documentBuilder = documentBuilderFactory . newDocumentBuilder ( ) ; Document document = documentBuilder . parse ( inputStream ) ; Node node = document . getDocumentElement ( ) ; return node ; } catch ( ParserConfigurationException canNotHappen ) { // Can not happen with a default configuration throw new XmlException ( "Could not create parser" , canNotHappen ) ; } catch ( SAXException e ) { throw new XmlException ( "XML parsing error" , e ) ; } catch ( IOException e ) { throw new XmlException ( "IO error while reading XML" , e ) ; } }
Creates an XML node by reading the contents of the given input stream .