Hi!
I need to read XML with the Xerces DOM Parser and also validate it against prepared XSD. So far, I have this:
import java.io.IOException;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
import com.sun.org.apache.xerces.internal.parsers.DOMParser;
public class XMLParser {
public XMLParser(String inputFile) {
DOMParser parser = new DOMParser();
try {
parser.parse(inputFile);
Document document = parser.getDocument();
} catch (IOException e) {
System.err.println (e);
}
catch (SAXException e) {
e.printStackTrace();
}
}
}
Now I tried to find how to do the validation, but without success. I believe it should be done by setting
parser.setFeature();
but I don't now, what should be in the argument. Or am I wrong and there is different way? Thanks!