这是我验证xml唯一问题的代码我在第2行导入org.apache.xerces ...我下载了xerces.jar然后将它作为外部jar从运行配置添加到类中,你能不能只要告诉我,如果我正在写它,如果是,那么为什么这个错误,如果没有那么我应该做什么。
import java.io.File;
import org.apache.xerces.parsers.DOMParser;
public class SchemaTest {
public static void main (String[] args) {
File docFile = new File("C:\\Users\\ahussain\\Desktop\\Xml_Validation\\memory.xml");
try {
DOMParser parser = new DOMParser();
parser.setFeature("http://xml.org/sax/features/validation", true);
parser.setProperty("http://apache.org/xml/properties/schema/external- noNamespaceSchemaLocation","memory.xsd");
ErrorChecker errors = new ErrorChecker();
parser.setErrorHandler(errors);
parser.parse("memory.xml");
} catch (Exception e) {
System.out.print("Problem parsing the file.");
}
}
}
答案 0 :(得分:0)
不是添加到运行配置,而是将jar添加到类路径中,
Project - BuildPath - 配置构建路径 - 库 - 添加jar。