public static DocumentBuilder getDocumentBuilder() { try { return documentBuilderFactory.newDocumentBuilder(); } catch (ParserConfigurationException e) { throw new XmlException("failed to create document builder", e); } }
public static DocumentBuilder getDocumentBuilder() { try { return documentBuilderFactory.newDocumentBuilder(); } catch (ParserConfigurationException e) { throw new XmlException("failed to create document builder", e); } }
public static Document parseXmlInputSource(InputSource inputSource) { Document document = null; try { document = getDocumentBuilder().parse(inputSource); } catch (IOException e) { throw new XmlException("could not read input", e); } catch (SAXException e) { throw new XmlException("failed to parse xml", e); } return document; }
public static Document parseXmlInputSource(InputSource inputSource) { Document document = null; try { document = getDocumentBuilder().parse(inputSource); } catch (IOException e) { throw new XmlException("could not read input", e); } catch (SAXException e) { throw new XmlException("failed to parse xml", e); } return document; }
public static Document parseXmlInputStream(InputStream inputStream) { Document document = null; try { document = getDocumentBuilder().parse(inputStream); } catch (IOException e) { throw new XmlException("could not read input", e); } catch (SAXException e) { throw new XmlException("failed to parse xml", e); } return document; }
public static Document parseXmlInputStream(InputStream inputStream) { Document document = null; try { document = getDocumentBuilder().parse(inputStream); } catch (IOException e) { throw new XmlException("could not read input", e); } catch (SAXException e) { throw new XmlException("failed to parse xml", e); } return document; }
public static String toString(Element element) { if (element == null) return "null"; Source source = new DOMSource(element); StringWriter stringWriter = new StringWriter(); Result result = new StreamResult(stringWriter); try { Transformer transformer = TransformerFactory.newInstance().newTransformer(); transformer.transform(source, result); } catch (TransformerException e) { throw new XmlException("could not transform to string: " + element, e); } return stringWriter.toString(); }
public static String toString(Element element) { if (element == null) return "null"; Source source = new DOMSource(element); StringWriter stringWriter = new StringWriter(); Result result = new StreamResult(stringWriter); try { Transformer transformer = TransformerFactory.newInstance().newTransformer(); transformer.transform(source, result); } catch (TransformerException e) { throw new XmlException("could not transform to string: " + element, e); } return stringWriter.toString(); }