List of usage examples for javax.xml.parsers DocumentBuilderFactory setValidating
public void setValidating(boolean validating)
From source file:DOMEdit.java
static public void main(String[] arg) { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setValidating(true); dbf.setNamespaceAware(true);//from w w w . j a va 2 s .c o m 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); addComment(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); dbf.setNamespaceAware(true);// w ww. j a va 2s . c o m 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); addProcessingInstruction(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); dbf.setNamespaceAware(true);/*from w w w. j a v a2 s . co m*/ 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); addCDATA(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); dbf.setNamespaceAware(true);/*from w ww . j a v a 2 s .c o m*/ 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); insert(doc, "newName", "1111111111", "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); dbf.setNamespaceAware(true);/*from w w w. j a va2 s .co m*/ 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); importName(doc, doc); write(doc); } catch (Exception e) { System.err.println(e); } }
From source file:DOMCopy.java
static public void main(String[] arg) { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setValidating(true); dbf.setNamespaceAware(true);/* w w w . j a v a 2 s. c o m*/ 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:ListMoviesXML.java
public static void main(String[] args) throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setIgnoringComments(true);/*from ww w . j a v a 2s .com*/ factory.setIgnoringElementContentWhitespace(true); factory.setValidating(true); DocumentBuilder builder = factory.newDocumentBuilder(); Document doc = builder.parse(new InputSource("y.xml")); Element root = doc.getDocumentElement(); Element movieElement = (Element) root.getFirstChild(); Movie m; while (movieElement != null) { m = getMovie(movieElement); String msg = Integer.toString(m.year); msg += ": " + m.title; msg += " (" + m.price + ")"; System.out.println(msg); movieElement = (Element) movieElement.getNextSibling(); } }
From source file:DOMEdit.java
static public void main(String[] arg) { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setValidating(true); dbf.setNamespaceAware(true);/* w ww . ja va 2 s . c o m*/ 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); dbf.setNamespaceAware(true);/*w w w . j a va 2 s . c o m*/ 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); dbf.setNamespaceAware(true);/*from w w w. j a v a 2 s . co m*/ 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); } }