G
gk
import org.apache.xerces.parsers.DOMParser;
import org.xml.sax.SAXException;
import org.w3c.dom.Document;
import java.io.IOException;
public class DOMExample{
public static void main(String args[]) throws IOException,
SAXException{
DOMParser parser = new DOMParser();
parser.parse("games.xml");
Document dom = parser.getDocument();
}
}
In the body of the main method, you have the code that creates a new
instance of the DOMParser class and assigns it to the variable named
parser. The second line calls the parse method of the DOMParser class
and passes in the name of the XML file you have created.
The parse method throws two exceptions: java.io.IOException and
org.xml.sax.SAXException. Rather than wrap the call to the parse method
in a try/catch, main throws these two exceptions.
Question:
import org.xml.sax.SAXException;
import org.w3c.dom.Document;
import java.io.IOException;
public class DOMExample{
public static void main(String args[]) throws IOException,
SAXException{
DOMParser parser = new DOMParser();
parser.parse("games.xml");
Document dom = parser.getDocument();
}
}
In the body of the main method, you have the code that creates a new
instance of the DOMParser class and assigns it to the variable named
parser. The second line calls the parse method of the DOMParser class
and passes in the name of the XML file you have created.
The parse method throws two exceptions: java.io.IOException and
org.xml.sax.SAXException. Rather than wrap the call to the parse method
in a try/catch, main throws these two exceptions.
Question: