Digester基于规则的XML文档解析,主要用于XML到Java对象的映射。Struts就是用Digester来处理XML配置文件的。而且Digester还包含一个写好的RSS解析器。
Maven:
<dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-digester3</artifactId> <version>3.2</version> <classifier>with-deps</classifier></dependency>下面是一段使用Digester解析XML的代码:
Digester digester = new Digester(); digester.setValidating(false); digester.addObjectCreate("foo", "mypackage.Foo"); digester.addSetProperties("foo"); digester.addObjectCreate("foo/bar", "mypackage.Bar"); digester.addSetProperties("foo/bar"); digester.addSetNext("foo/bar", "addBar", "mypackage.Bar"); Foo foo = (Foo) digester.parse();Digester3.xJavaDoc: https://tool.oschina.net/apidocs/apidoc?api=commons-digester
Digester2.xJavaDoc:https://tool.oschina.net/apidocs/apidoc?api=commons-digester-2.1
评论