List of usage examples for javax.xml.parsers DocumentBuilderFactory setIgnoringComments
public void setIgnoringComments(boolean ignoreComments)
From source file:Main.java
public static Document loadString(String paramString) throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setIgnoringComments(false); factory.setIgnoringElementContentWhitespace(false); factory.setValidating(false);/*ww w .j a v a 2 s.co m*/ factory.setCoalescing(false); DocumentBuilder builder = factory.newDocumentBuilder(); char[] arrayOfChar = new char[paramString.length()]; paramString.getChars(0, paramString.length(), arrayOfChar, 0); InputSource input = new InputSource(new CharArrayReader(arrayOfChar)); return builder.parse(input); }
From source file:Main.java
public static Document load(String path) throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setIgnoringComments(false); factory.setIgnoringElementContentWhitespace(false); factory.setValidating(false);//from w w w . ja v a 2s . c o m factory.setCoalescing(true); DocumentBuilder builder = factory.newDocumentBuilder(); return builder.parse(path); }
From source file:Main.java
public static Document load(File file) throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setIgnoringComments(false); factory.setIgnoringElementContentWhitespace(false); factory.setValidating(false);// w ww . j a va 2 s .c om factory.setCoalescing(true); DocumentBuilder builder = factory.newDocumentBuilder(); return builder.parse(file); }
From source file:Main.java
private static DocumentBuilder newDocumentBuilder() throws ParserConfigurationException { final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setIgnoringComments(false); factory.setIgnoringElementContentWhitespace(true); return factory.newDocumentBuilder(); }
From source file:Main.java
public static Document blankDocument(String paramString) throws Exception { DocumentBuilderFactory localDocumentBuilderFactory = DocumentBuilderFactory.newInstance(); localDocumentBuilderFactory.setIgnoringComments(false); localDocumentBuilderFactory.setIgnoringElementContentWhitespace(false); localDocumentBuilderFactory.setValidating(false); localDocumentBuilderFactory.setCoalescing(false); DocumentBuilder localDocumentBuilder = localDocumentBuilderFactory.newDocumentBuilder(); Document localDocument = localDocumentBuilder.newDocument(); Element localElement = localDocument.createElement(paramString); localDocument.appendChild(localElement); return localDocument; }
From source file:Main.java
public static Document loadString(String domContent) throws Exception { javax.xml.parsers.DocumentBuilderFactory factory = javax.xml.parsers.DocumentBuilderFactory.newInstance(); factory.setIgnoringComments(false); factory.setIgnoringElementContentWhitespace(false); factory.setValidating(false);/* w w w. j ava 2s . c o m*/ factory.setCoalescing(false); DocumentBuilder builder = factory.newDocumentBuilder(); char[] chars = new char[domContent.length()]; domContent.getChars(0, domContent.length(), chars, 0); InputSource is = new InputSource(new CharArrayReader(chars)); return (builder.parse(is)); }
From source file:Main.java
public static DocumentBuilder getDocumentBuilder() { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true);/*from ww w . j av a 2 s . c o m*/ factory.setIgnoringComments(true); DocumentBuilder db; try { db = factory.newDocumentBuilder(); return db; } catch (ParserConfigurationException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; }
From source file:Main.java
public final static DocumentBuilder getDocumentBuilder() throws ParserConfigurationException { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true);// www. j a va2 s.c o m factory.setIgnoringComments(true); return factory.newDocumentBuilder(); }
From source file:Main.java
private static DocumentBuilder getDocumentBuilder() throws ParserConfigurationException { if (db == null) { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setValidating(false);//from w ww. j a v a 2s . c om dbf.setIgnoringComments(true); dbf.setFeature("http://xml.org/sax/features/namespaces", false); dbf.setFeature("http://xml.org/sax/features/validation", false); dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false); dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); db = dbf.newDocumentBuilder(); } return db; }
From source file:Main.java
/** * Builds new DocumentBuilder//from w ww . j av a 2 s . c om * * @return DocumentBuilder * @throws CitationStyleManagerException */ public static DocumentBuilder createDocumentBuilder() { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setValidating(false); dbf.setIgnoringComments(true); dbf.setNamespaceAware(false); try { return dbf.newDocumentBuilder(); } catch (ParserConfigurationException e) { throw new RuntimeException("Failed to create a document builder factory", e); } }