List of usage examples for javax.xml.parsers ParserConfigurationException printStackTrace
public void printStackTrace()
From source file:Main.java
public static NodeList loadNodeList(String file, String path) { try {/*from ww w . j a va2 s .c om*/ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder; builder = factory.newDocumentBuilder(); Document doc = builder.parse(file); return getDocNodeList(doc, path); } catch (ParserConfigurationException e) { e.printStackTrace(); } catch (SAXException e) { System.out.println("ERROR: your xml file " + file + " is not well-formed"); // e.printStackTrace(); } catch (IOException e) { System.out.println("ERROR: input file " + file + " not found"); // e.printStackTrace(); } return null; }
From source file:Main.java
public static ArrayList<String> getFontSizeList() { ArrayList<String> fontList = new ArrayList<String>(); DocumentBuilderFactory dbfFont = null; DocumentBuilder dbFont = null; Document domFont = null;// www.j a v a2 s . com try { dbfFont = DocumentBuilderFactory.newInstance(); String fontSizeFileName = "resources/FontSizes.xml"; //Using factory get an instance of document builder dbFont = dbfFont.newDocumentBuilder(); //parse using builder to get DOM representation of the XML file domFont = dbFont.parse(fontSizeFileName); //get the root elememt Element docEle = domFont.getDocumentElement(); //get a nodelist of <sizes> elements NodeList sizeList = docEle.getElementsByTagName("size"); if (sizeList != null && sizeList.getLength() > 0) { for (int i = 0; i < sizeList.getLength(); i++) { //get the employee element Element sizeElement = (Element) sizeList.item(i); fontList.add(sizeElement.getTextContent()); } } } catch (ParserConfigurationException pce) { pce.printStackTrace(); } catch (SAXException se) { se.printStackTrace(); } catch (IOException ioe) { ioe.printStackTrace(); } return fontList; }
From source file:Main.java
public static DocumentBuilder getBuilder() { if (builder == null) try {//from ww w .j av a2 s . c o m builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); } catch (ParserConfigurationException e) { // TODO come up with some sort of recovery process e.printStackTrace(); } return builder; }
From source file:Main.java
public static Document createDocument() { try {/*from www . j a v a 2s .com*/ return DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); } catch (ParserConfigurationException e) { // How can a vanilla instance throw a configuration exception? e.printStackTrace(); assert false : e.getMessage(); throw new RuntimeException(e); } }
From source file:Main.java
public static Document getDocument(String file_path) { try {/* w ww . j a v a2 s.c o m*/ DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance(); domFactory.setIgnoringComments(true); DocumentBuilder builder; builder = domFactory.newDocumentBuilder(); Document doc = builder.parse(new File(file_path)); return doc; } catch (ParserConfigurationException e) { e.printStackTrace(); } catch (SAXException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; }
From source file:Main.java
public static Document createXML(byte[] xml) { //Get the DOM Builder Factory DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); //Get the DOM Builder DocumentBuilder builder = null; try {//from w w w. j a va2 s. c om builder = factory.newDocumentBuilder(); } catch (ParserConfigurationException e) { e.printStackTrace(); } //Load and Parse the XML document //document contains the complete XML as a Tree. Document document = null; try { document = builder.parse(new ByteArrayInputStream(xml)); } catch (SAXException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return document; }
From source file:Main.java
public static Document createXML(String xml) { //Get the DOM Builder Factory DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); //Get the DOM Builder DocumentBuilder builder = null; try {/*from www .ja v a 2 s . c o m*/ builder = factory.newDocumentBuilder(); } catch (ParserConfigurationException e) { e.printStackTrace(); } //Load and Parse the XML document //document contains the complete XML as a Tree. Document document = null; InputSource source = new InputSource(new StringReader(xml)); try { document = builder.parse(source); } catch (SAXException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return document; }
From source file:Main.java
private static void readXMLAux(File file) { dbf = DocumentBuilderFactory.newInstance(); db = null;/*from w w w. j a v a 2s . co m*/ try { db = dbf.newDocumentBuilder(); } catch (ParserConfigurationException e) { // TODO Auto-generated catch block e.printStackTrace(); } doc = null; try { doc = db.parse(file); } catch (SAXException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } root = doc.getDocumentElement(); }
From source file:Main.java
public static Document StringToXML(String xmlString) { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = null; Document document = null;//from ww w. j a va2s . c o m try { builder = factory.newDocumentBuilder(); } catch (ParserConfigurationException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { document = builder.parse(new InputSource(new StringReader(xmlString))); } catch (SAXException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return document; }
From source file:Main.java
public static Document DocumentFactory(Path xmlfile) { //get document object of the xml file DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); Document document = null;/*from ww w . j a v a2 s. com*/ try { DocumentBuilder builder = builderFactory.newDocumentBuilder(); document = builder.parse(xmlfile.toFile()); } catch (ParserConfigurationException e) { log.error("DOM parser configuration exception"); e.printStackTrace(); } catch (SAXException e) { log.error("DOM parse error"); e.printStackTrace(); } catch (IOException e) { log.error("IO exception"); e.printStackTrace(); } return document; }