I currently have the following XML
file.
http://www.cse.unsw.edu.au/~cs9321/14s1/assignments/musicDb.xml
My XMLParser.java
class.
package edu.unsw.comp9321.assignment1;
import java.io.File;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
public class XMLParser {
public void search () {
try{
File fXmlFile = new File("/COMP9321Assignment1/xml/musicDb.xml");
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(fXmlFile);
System.out.println("Root element :" + doc.getDocumentElement().getNodeName());
} catch (Exception e) {
e.printStackTrace();
}
}
}
I create an object in another class and call the search
but I keep receiving the above stated error.
Would anyone know what the problem might be?
Thanks for your help.