Analyze XML data with Digester class

xiaoxiao2021-03-06  74

The Digester class is org.apache.commons.digester.digester.

Jakarta's Digester framework has developed from the Struts framework,

1. First define a UserDatabase.xml

YJS

821001

Http://free2.e-168.cn/jisong/

Each label corresponds to the corresponding matching mode as follows: -------------------------------------- ------ | Tags | Matching mode | -------------------------------------- -------- Username> User> User / UserName UserS / User / Password User / WebPage

User / USER / Address -------------------------------------------------will The XML file is treated as a tree, then the matching mode of the label is the matching of the root element to the current element, and the matching mode can be easily locate the processing element. To handle these elements, you need some processing rules, but fortunately org.apache.commons.digester.Rules can send a lot to them. All defined Rule objects can be found in org.apache.commons.digester. Common rules: ObjectCreate, create an object instance. SetProperties, associate the tag properties (Attribute) is associated with the properties of the objects you want to create. BeanPropertySetter, associate the tag contains the label with the properties of the object to be created, set, to set the action when the next label is encountered. CallMethod, setting the method to be called when the matching mode is found. CallParam, setting the parameter values ​​required to specify the method in the corresponding CallMethod.

转载请注明原文地址:https://www.9cbs.com/read-92641.html

New Post(0)