Here you can find the source of parseData(String filename)
public static Document parseData(String filename)
//package com.java2s; /*/*from www. java 2 s .co m*/ * XMLUtility.java 2/6/13 1:04 PM * * Copyright (C) 2012-2013 Nick Ma * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 3 * of the License, or any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ import java.io.File; import java.io.IOException; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.w3c.dom.Document; import org.xml.sax.SAXException; public class Main { public static Document parseData(String filename) { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); Document document = null; try { DocumentBuilder myDoc = factory.newDocumentBuilder(); File xmlFile = new File(filename); document = myDoc.parse(xmlFile); } catch (SAXException e) { e.printStackTrace(); } catch (ParserConfigurationException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return document; } }