/** * Returns a new, empty DOM document. * * @return Returns a new DOM document. */ public static Document createDocument() { return mxXmlUtils.getDocumentBuilder().newDocument(); }
/** * Returns a new DOM document for the given URI. External entities and DTDs are ignored. * * @param uri * URI to parse into the document. * @return Returns a new DOM document for the given URI. */ public static Document loadDocument(String uri) { try { return mxXmlUtils.getDocumentBuilder().parse(uri); } catch (Exception e) { log.log(Level.SEVERE, "Failed to load the document from " + uri, e); } return null; }
/** * Returns a new document for the given XML string. External entities and DTDs are ignored. * * @param xml * String that represents the XML data. * @return Returns a new XML document. */ public static Document parseXml(String xml) { try { return getDocumentBuilder().parse(new InputSource(new StringReader(xml))); } catch (Exception e) { log.log(Level.SEVERE, "Failed to parse XML", e); } return null; }