Parsing documents with DOM3
import org.w3c.dom.*;
import org.w3c.dom.ls.*;
import org.w3c.dom.bootstrap.*;
public class DOM3ParserMaker {
public static void main(String[] args)
throws ClassNotFoundException, InstantiationException, IllegalAccessException {
System.setProperty(DOMImplementationRegistry.PROPERTY,
"org.apache.xerces.dom.DOMImplementationSourceImpl");
DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
DOMImplementation impl = registry.getDOMImplementation("LS-Load");
if (impl == null) {
System.err.println("Coudl not locate a DOM3 Parser");
return;
}
DOMImplementationLS implls = (DOMImplementationLS) impl;
LSParser parser = implls.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS , null);
for (int i = 0; i < args.length; i++) {
try {
Document d = parser.parseURI(args[i]);
}
catch (DOMException ex) {
System.err.println(ex);
}
}
}
}