Here you can find the source of getXmlDocument(File file)
Parameter | Description |
---|---|
file | xml file |
public static Document getXmlDocument(File file)
//package com.java2s; import java.io.File; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; public class Main { /**/*from www . ja v a2s.c om*/ * Gets Document representation of xml file * * @param file * xml file * @return Document object */ public static Document getXmlDocument(File file) { try { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); Document doc = builder.parse(file); return doc; } catch (Exception e) { throw new RuntimeException("Could not parse XML document", e); } } }