List of usage examples for javax.xml.parsers ParserConfigurationException printStackTrace
public void printStackTrace()
From source file:Main.java
public static Document createDoc() { Document document = null;/*from w ww .j a v a 2 s. c om*/ DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); try { DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); document = docBuilder.newDocument(); } catch (ParserConfigurationException e) { e.printStackTrace(); } return document; }
From source file:Main.java
public static Document read(String path) { Document doc = null;/*from ww w .ja va 2 s.c o m*/ try { File file = new File(path); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); if (file.length() != 0) { doc = db.parse(file); } else { return null; } } catch (ParserConfigurationException e) { e.printStackTrace(); } catch (SAXException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return doc; }
From source file:Main.java
public static Document String2XML(String xmlStr) { try {/*w w w .j a v a2 s .co m*/ StringReader sr = new StringReader(xmlStr); InputSource is = new InputSource(sr); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); return builder.parse(is); } catch (ParserConfigurationException e) { e.printStackTrace(); } catch (SAXException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; }
From source file:Main.java
/** * Creates the dom.//from w ww. j a v a 2 s. c o m * * @param documentElementName * the document element name * @return the document */ public static Document createDom(String documentElementName) { try { DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); DOMImplementation domImpl = documentBuilder.getDOMImplementation(); Document document = domImpl.createDocument(NS_PIPELINE_DATA, documentElementName, null); return document; } catch (ParserConfigurationException e) { e.printStackTrace(); return null; } }
From source file:Main.java
public static Document createDocumentNode() { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = null; try {// ww w . j a v a 2s . co m builder = factory.newDocumentBuilder(); } catch (ParserConfigurationException e) { e.printStackTrace(); } return builder.newDocument(); }
From source file:Main.java
/** * Creates W3C DOM Document object from XML file * @param filePath path to xml file including file name and extension *///w w w.ja v a2 s . co m public static Document parseXml(String filePath) { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); try { DocumentBuilder db = dbf.newDocumentBuilder(); Document doc = db.parse(filePath); doc.getDocumentElement().normalize(); return doc; } catch (ParserConfigurationException pce) { pce.printStackTrace(); return null; } catch (SAXException se) { se.printStackTrace(); return null; } catch (IOException ioe) { ioe.printStackTrace(); return null; } }
From source file:Main.java
public static void buildSkeleton() { try {// w w w . j a va2s .c o m DocumentBuilderFactory dFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder dBldr = dFactory.newDocumentBuilder(); Document doc = dBldr.newDocument(); Element rootElement = doc.createElement("hooks"); doc.appendChild(rootElement); write(doc); } catch (ParserConfigurationException e) { e.printStackTrace(); } }
From source file:Main.java
public static Node createDocument(String rootElementName) { try {/*w w w.j a va 2 s. c om*/ DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder; docBuilder = docFactory.newDocumentBuilder(); Document doc = docBuilder.newDocument(); Element rootElement = doc.createElement(rootElementName); doc.appendChild(rootElement); return rootElement; } catch (ParserConfigurationException e) { e.printStackTrace(); } return null; }
From source file:Utils.java
public static Document newEmptyDocument() { DocumentBuilderFactory factory = null; DocumentBuilder builder = null; Document ret;// w w w.j a v a2s . c o m try { factory = DocumentBuilderFactory.newInstance(); builder = factory.newDocumentBuilder(); } catch (ParserConfigurationException e) { e.printStackTrace(); } ret = builder.newDocument(); return ret; }
From source file:Main.java
public static Element GetXmlDoc(String filePath) { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = null;/* ww w . java 2 s.c om*/ try { db = dbf.newDocumentBuilder(); } catch (ParserConfigurationException pce) { pce.printStackTrace(); } Document doc = null; try { File f = new File(filePath); doc = db.parse(f); } catch (Exception e) { e.printStackTrace(); } return (Element) doc.getDocumentElement(); }