Here you can find the source of parse(String fileName)
public static Document parse(String fileName)
//package com.java2s; /******************************************************************************* * Copyright (c) 2009 CollabNet./*from ww w .j ava 2 s . c o m*/ * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * CollabNet - initial API and implementation ******************************************************************************/ import java.io.File; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; public class Main { public static Document parse(String fileName) { Document document = null; DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setValidating(false); factory.setNamespaceAware(true); try { DocumentBuilder builder = factory.newDocumentBuilder(); document = builder.parse(new File(fileName)); return document; } catch (Exception e) { System.out.println(e.getMessage()); } return null; } }