package edu.brown.cs.student.term.parsing; import org.w3c.dom.Document; import org.xml.sax.SAXException; import java.io.File; import java.io.IOException; public class LocalXmlParser extends XmlParser { public LocalXmlParser() { super(); } /** * Method used to parse the xml file. * * @param pathToXml The path to the xml text file. * @return The tree structure parsed as an xml doc. */ @Override public Document parse(String pathToXml) { // TODO: change to online hosted file option // Creating the file reference. System.err.println("LOG: To make file reference for " + pathToXml + " in " + getClass()); File file = new File(pathToXml); // Parsing the file. try { System.err.println("LOG: Calling builder.parse() in " + getClass()); return builder.parse(file); } catch (SAXException e) { System.err.println("INTERNAL: SAX " + getClass() + " : " + e.getClass()); } catch (IOException e) { System.err.println("INTERNAL: IO " + getClass() + " : " + e.getClass()); } return null; } }