Actually added sub modules this time

#story[778]
This commit is contained in:
Erika Savell
2017-04-20 11:16:19 +12:00
parent 669718d406
commit a584400e24
80 changed files with 9020 additions and 0 deletions
+40
View File
@@ -0,0 +1,40 @@
package seng302;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException;
import java.io.InputStream;
/**
* Created by fwy13 on 26/03/2017.
*/
public abstract class XMLReader {
protected Document doc;
public XMLReader(String filePath) throws ParserConfigurationException, IOException, SAXException {
InputStream fXmlFile = getClass().getClassLoader().getResourceAsStream(filePath);
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
doc = dBuilder.parse(fXmlFile);
doc.getDocumentElement().normalize();
}
public Document getDocument() {
return doc;
}
public String getTextValueOfNode(Element n, String tagName) {
return n.getElementsByTagName(tagName).item(0).getTextContent();
}
public String getAttribute(Element n, String attr) {
return n.getAttribute(attr);
}
}