public static Element parse ( InputStream xmlStream , DocumentBuilder builder ) throws IOException { try { Document doc ; synchronized ( builder ) //synchronize to prevent concurrent parsing on the same DocumentBuilder { doc = builder . parse ( xmlStream ) ; } return doc . getDocumentElement ( ) ; } catch ( SAXException se ) { throw new IOException ( se . toString ( ) ) ; } finally { xmlStream . close ( ) ; } }
Parse the given XML stream and return the root Element