/** * Returns the root element of a given input stream * * @param is stream to parse * @return XML DOM element, or null if unable to parse stream */ public static Element getDocumentRoot(InputStream is) { Document doc; try { InputSource xmlInp = new InputSource(is); DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); docBuilderFactory.setNamespaceAware(true); DocumentBuilder parser = docBuilderFactory.newDocumentBuilder(); doc = parser.parse(xmlInp); Element root = doc.getDocumentElement(); root.normalize(); return root; } catch (SAXParseException err) { log.configuratorSAXParseError(err); } catch (SAXException e) { log.configuratorSAXError(e); } catch (Exception pce) { log.configuratorError(pce); } return null; }