您可以创建一个扩展org.xml.sax.helpers.DefaultHandler的类并调用
start_(Attributes attrs);
和
end_();
因为它是:
start_request_queue(attrs);
等等
然后扩展该类并实现所需的xml配置文件解析器。 例:
“); java.lang.reflect.Method m = getClass()。getDeclaredMethod(“ start” + mname,args); m.invoke(this,new Object [] {uri,(org.xml.sax.Attributes)attrs}); }
捕获(IllegalAccessException e){ 抛出新的RuntimeException(e); }
catch(NoSuchMethodException e){ 抛出新的RuntimeException(e); }
捕获(java.lang.reflect.InvocationTargetException e){ org.xml.sax.SAXException se = 新的org.xml.sax.SAXException(e.getTargetException()); se.setStackTrace(e.getTargetException()。getStackTrace()); }
在特定的配置解析器中:
public void start_Request(String uri, org.xml.sax.Attributes attrs) {
// make sure to read attributes correctly
System.err.println("Request, name="+ attrs.getValue(0);
}