Here you can find the source of loadXmlFromFile(String xmlFileName)
Parameter | Description |
---|---|
xmlFileName | - name of the file on disk, including path |
public static Document loadXmlFromFile(String xmlFileName)
//package com.java2s; import java.io.File; import java.io.IOException; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.w3c.dom.Document; import org.xml.sax.SAXException; public class Main { /**// w w w. j a v a 2 s. c om * Loads an xml file on disk into a document * * @param xmlFileName - name of the file on disk, including path * @return Document - loaded from the specified xml file on disk */ public static Document loadXmlFromFile(String xmlFileName) { DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); docFactory.setNamespaceAware(true); try { return docFactory.newDocumentBuilder().parse(new File(xmlFileName)); } catch (ParserConfigurationException e) { throw new RuntimeException("Error setting up UI xml page model parser -- " + e.getMessage()); } catch (SAXException e) { throw new RuntimeException( "Error parsing UI xml page model file [" + xmlFileName + "] -- " + e.getMessage()); } catch (IOException e) { throw new RuntimeException( "Error opening or reading UI xml page model file [" + xmlFileName + "] -- " + e.getMessage()); } } }