code: protected static Element parse(InputStream stream) throws IOException {
          try {
              return DBF.get().newDocumentBuilder().parse(stream).getDocumentElement();
          }
          catch (SAXException | ParserConfigurationException e) {
              throw new IOException("parsing stream failed", e);
          }
          finally {
              stream.close();
          }
      }
docs: parse (and close) the Inputstream and return the containing document, xml error are converted
  to IOExceptions for unified handling
  
  @param stream
  @return
  @throws IOException