@Test public void testXmlToDocument() { final Document d1 = DOMUtils.xmlToDocument(POLICY_STRING1); final Document d2 = DOMUtils.xmlToDocument(POLICY_STRING2); assertNotNull(d1); assertNotNull(d2); }
public static Document xmlToDocument(String xmlString) { try { final DocumentBuilderFactory dbf = DocumentBuilderFactory .newInstance(); dbf.setValidating(false); dbf.setNamespaceAware(true); final DocumentBuilder db = dbf.newDocumentBuilder(); final InputSource source = new InputSource(new StringReader( xmlString)); final Document doc = db.parse(source); Assert.notNull(doc, "XML string cannot be converted to Document object!"); return doc; } catch (ParserConfigurationException | SAXException | IOException | IllegalArgumentException e) { throw new DOMUtilsException(e); } }
DOMUtils { public static Document xmlToDocument(String xmlString) { try { final DocumentBuilderFactory dbf = DocumentBuilderFactory .newInstance(); dbf.setValidating(false); dbf.setNamespaceAware(true); final DocumentBuilder db = dbf.newDocumentBuilder(); final InputSource source = new InputSource(new StringReader( xmlString)); final Document doc = db.parse(source); Assert.notNull(doc, "XML string cannot be converted to Document object!"); return doc; } catch (ParserConfigurationException | SAXException | IOException | IllegalArgumentException e) { throw new DOMUtilsException(e); } } }
DOMUtils { public static Document xmlToDocument(String xmlString) { try { final DocumentBuilderFactory dbf = DocumentBuilderFactory .newInstance(); dbf.setValidating(false); dbf.setNamespaceAware(true); final DocumentBuilder db = dbf.newDocumentBuilder(); final InputSource source = new InputSource(new StringReader( xmlString)); final Document doc = db.parse(source); Assert.notNull(doc, "XML string cannot be converted to Document object!"); return doc; } catch (ParserConfigurationException | SAXException | IOException | IllegalArgumentException e) { throw new DOMUtilsException(e); } }  }
DOMUtils { public static Document xmlToDocument(String xmlString) { try { final DocumentBuilderFactory dbf = DocumentBuilderFactory .newInstance(); dbf.setValidating(false); dbf.setNamespaceAware(true); final DocumentBuilder db = dbf.newDocumentBuilder(); final InputSource source = new InputSource(new StringReader( xmlString)); final Document doc = db.parse(source); Assert.notNull(doc, "XML string cannot be converted to Document object!"); return doc; } catch (ParserConfigurationException | SAXException | IOException | IllegalArgumentException e) { throw new DOMUtilsException(e); } }  static Document bytesToDocument(byte[] bytes); static byte[] documentToBytes(Document xmlDocument); static String documentToXml(Document xmlDocument); static Optional<Node> getNode(Document xmlDocument,
			String xPathExpr, String... arguments); static Optional<NodeList> getNodeList(Document xmlDocument,
			String xPathExpr, String... arguments); static Document xmlToDocument(String xmlString); }
DOMUtils { public static Document xmlToDocument(String xmlString) { try { final DocumentBuilderFactory dbf = DocumentBuilderFactory .newInstance(); dbf.setValidating(false); dbf.setNamespaceAware(true); final DocumentBuilder db = dbf.newDocumentBuilder(); final InputSource source = new InputSource(new StringReader( xmlString)); final Document doc = db.parse(source); Assert.notNull(doc, "XML string cannot be converted to Document object!"); return doc; } catch (ParserConfigurationException | SAXException | IOException | IllegalArgumentException e) { throw new DOMUtilsException(e); } }  static Document bytesToDocument(byte[] bytes); static byte[] documentToBytes(Document xmlDocument); static String documentToXml(Document xmlDocument); static Optional<Node> getNode(Document xmlDocument,
			String xPathExpr, String... arguments); static Optional<NodeList> getNodeList(Document xmlDocument,
			String xPathExpr, String... arguments); static Document xmlToDocument(String xmlString); static final String DEFAULT_ENCODING; }