blob: 27c398858d36e16193b1f61592a09379ef5d08bd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
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;
}
}
|