Thursday, February 09, 2006
Loading XML File With Xerces
Here is a simple example of using Xerces to load an XML document into the DOM.
import org.apache.xerces.parsers.*;
import org.w3c.dom.traversal.*;
import org.w3c.dom.*;
public class Example {
static Document document;
public static void main (String[] ARGS) {
try {
DOMParser parser = new DOMParser();
parser.parse("./sample.xml");
document = parser.getDocument();
}
catch (Exception e) {
e.printStackTrace(System.err);
}
}
}