Jakarta-common-digester Use Notes

Source: Internet
Author: User
Tags xml parser

Digester is not an XML Parser, it simply uses digester to encapsulate a higher level of sax, mapping XML to JavaBean. We don't need to understand the parsing process of sax and Dom, as long as we add some parsing rules to digester, we can parse an XML file. Digester uses the stack to hold the XML node (Stack.push () method), which is ejected (Stack.pup () method) when all child nodes nested in the XML node are resolved. The biggest advantage of Digester is the use of pattern matching to represent the parent-child relationship between nodes in an XML file.

The code is as follows:

Students.xml

<?xml version="1.0" encoding="UTF-8" ?>
<stuClass name="fddfdf">
   <student>
     <name from="cn">Java Boy</name>
     <course>JSP</course>
   </student>
   <student>
     <name>Java Girl</name>
     <course>EJB</course>
   </student>
</stuClass>

Model class: Student.java

package demo.javabean;

public class Student ...{

   private String name;
   private String from;
   private String course;

   public String getName() ...{
     return name;
   }
   public void setName(String name) ...{
     this.name = name;
   }
   public String getFrom() ...{
     return from;
   }
   public void setFrom(String from) ...{
     this.from = from;
   }
   public String getCourse() ...{
     return course;
   }
   public void setCourse(String course) ...{
     this.course = course;
   }
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.