Her er løsningen:
import org.apache.xerces.parsers.DOMParser;
import org.apache.xerces.dom.DocumentImpl;
public class Parse {
public static void main(String[] args) {
try {
DOMParser parser = new DOMParser();
SAXErrorHandler seh = new SAXErrorHandler();
parser.setErrorHandler(seh);
parser.setFeature("
http://xml.org/sax/features/validation", true);
parser.setFeature("
http://apache.org/xml/features/validation/schema", true);
DocumentImpl doc = new DocumentImpl();
parser.parse("
http://localhost:8080/test/GetList.xml");
}
catch (Throwable e) {
e.printStackTrace(System.err);
}
}
}
import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
public class SAXErrorHandler
implements ErrorHandler {
public void error(SAXParseException ex)
throws SAXException{
throw ex;
}
public void fatalError(SAXParseException ex)
throws SAXException{
throw ex;
}
public void warning(SAXParseException ex)
throws SAXException{
throw ex;
}
}