List of usage examples for javax.xml.parsers DocumentBuilderFactory setIgnoringElementContentWhitespace
public void setIgnoringElementContentWhitespace(boolean whitespace)
From source file:DOMCopy.java
static public void main(String[] arg) { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setValidating(true);//w ww.j ava2 s . c o m dbf.setNamespaceAware(true); dbf.setIgnoringElementContentWhitespace(true); Document doc = null; try { DocumentBuilder builder = dbf.newDocumentBuilder(); builder.setErrorHandler(new MyErrorHandler()); InputSource is = new InputSource("personWithDTD.xml"); doc = builder.parse(is); write(doc); } catch (Exception e) { System.err.println(e); } }
From source file:DOMEdit.java
static public void main(String[] arg) { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setValidating(true);/*w w w. ja v a 2 s . c o m*/ dbf.setNamespaceAware(true); dbf.setIgnoringElementContentWhitespace(true); Document doc = null; try { DocumentBuilder builder = dbf.newDocumentBuilder(); builder.setErrorHandler(new MyErrorHandler()); InputSource is = new InputSource("personWithDTD.xml"); doc = builder.parse(is); modifyingTextbyCuttingandPasting(doc); write(doc); } catch (Exception e) { System.err.println(e); } }
From source file:DOMEdit.java
static public void main(String[] arg) { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setValidating(true);/*from w w w .j a v a2s. co m*/ dbf.setNamespaceAware(true); dbf.setIgnoringElementContentWhitespace(true); Document doc = null; try { DocumentBuilder builder = dbf.newDocumentBuilder(); builder.setErrorHandler(new MyErrorHandler()); InputSource is = new InputSource("personWithDTD.xml"); doc = builder.parse(is); editTextbyInsertionandReplacement(doc); write(doc); } catch (Exception e) { System.err.println(e); } }
From source file:DOMEdit.java
static public void main(String[] arg) { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setValidating(true);//from ww w . ja va 2s . c o m dbf.setNamespaceAware(true); dbf.setIgnoringElementContentWhitespace(true); Document doc = null; try { DocumentBuilder builder = dbf.newDocumentBuilder(); builder.setErrorHandler(new MyErrorHandler()); InputSource is = new InputSource("personWithDTD.xml"); doc = builder.parse(is); addAttribute(doc); write(doc); } catch (Exception e) { System.err.println(e); } }
From source file:DOMEdit.java
static public void main(String[] arg) { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setValidating(true);//from w w w. j a va 2 s .c o m dbf.setNamespaceAware(true); dbf.setIgnoringElementContentWhitespace(true); Document doc = null; try { DocumentBuilder builder = dbf.newDocumentBuilder(); builder.setErrorHandler(new MyErrorHandler()); InputSource is = new InputSource("personWithDTD.xml"); doc = builder.parse(is); delAttribute(doc); write(doc); } catch (Exception e) { System.err.println(e); } }
From source file:DOMDump.java
static public void main(String[] arg) { String filename = null;/*from w w w . j a v a 2 s.c o m*/ boolean validate = false; if (arg.length == 1) { filename = arg[0]; } else if (arg.length == 2) { if (!arg[0].equals("-v")) usage(); validate = true; filename = arg[1]; } else { usage(); } DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setValidating(validate); dbf.setNamespaceAware(true); dbf.setIgnoringElementContentWhitespace(true); // Parse the input to produce a parse tree with its root // in the form of a Document object Document doc = null; try { DocumentBuilder builder = dbf.newDocumentBuilder(); builder.setErrorHandler(new MyErrorHandler()); InputSource is = new InputSource(filename); doc = builder.parse(is); } catch (SAXException e) { System.exit(1); } catch (ParserConfigurationException e) { System.err.println(e); System.exit(1); } catch (IOException e) { System.err.println(e); System.exit(1); } // Use a TreeDumper to list the tree TreeDumper td = new TreeDumper(); td.dump(doc); }
From source file:DOMEdit.java
static public void main(String[] arg) { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setValidating(true);// ww w. j a va 2 s. com dbf.setNamespaceAware(true); dbf.setIgnoringElementContentWhitespace(true); Document doc = null; try { DocumentBuilder builder = dbf.newDocumentBuilder(); builder.setErrorHandler(new MyErrorHandler()); InputSource is = new InputSource("personWithDTD.xml"); doc = builder.parse(is); deleteFirstElement(doc); write(doc); } catch (Exception e) { System.err.println(e); } }
From source file:DOMEdit.java
static public void main(String[] arg) { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setValidating(true);/*from www . j av a 2 s . co m*/ dbf.setNamespaceAware(true); dbf.setIgnoringElementContentWhitespace(true); Document doc = null; try { DocumentBuilder builder = dbf.newDocumentBuilder(); builder.setErrorHandler(new MyErrorHandler()); InputSource is = new InputSource("personWithDTD.xml"); doc = builder.parse(is); addFragment(doc); write(doc); } catch (Exception e) { System.err.println(e); } }
From source file:DOMEdit.java
static public void main(String[] arg) { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setValidating(true);/*from w w w . j ava 2s .com*/ dbf.setNamespaceAware(true); dbf.setIgnoringElementContentWhitespace(true); Document doc = null; try { DocumentBuilder builder = dbf.newDocumentBuilder(); builder.setErrorHandler(new MyErrorHandler()); InputSource is = new InputSource("personWithDTD.xml"); doc = builder.parse(is); newEmail(doc, "B D", "newEmail"); write(doc); } catch (Exception e) { System.err.println(e); } }
From source file:DOMEdit.java
static public void main(String[] arg) { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setValidating(true);/*from www . j a v a 2 s . co m*/ dbf.setNamespaceAware(true); dbf.setIgnoringElementContentWhitespace(true); Document doc = null; try { DocumentBuilder builder = dbf.newDocumentBuilder(); builder.setErrorHandler(new MyErrorHandler()); InputSource is = new InputSource("personWithDTD.xml"); doc = builder.parse(is); dupAttributes(doc); write(doc); } catch (Exception e) { System.err.println(e); } }