xml - Parse document by template in Java -


Is there a ready-to-use Java library, which is given a template, can read an XML file Does it compile with that template and parse its value in Java class? The job is in the ordered direction on the basis of velocity.

For example, the following template

  & lt; Person & gt; & Lt; Name & gt; $ {Person.name} & lt; / Name & gt; & Lt; Age & gt; $ {Person.age} & lt; / Age & gt; & Lt; / Person & gt;   

and input file

  & lt; Person & gt; & Lt; Name & gt; John & lt; / Name & gt; & Lt; Age & gt; 20 & lt; / Age & gt; & Lt; / Person & gt;   

This class can read its values ​​

  class person {public string name; People's age }  Update:  The general idea of ​​the above example is to show the meaning and nothing to do with its sorting, the actual example can also have elements and attributes Which are in conformance with the fields related to different Java objects and can have structure in the input file, which can be used in various attributes of various XML elements, You can not be. So this is not a serialization problem.  

You can also see Apache digester: - They do not use a template-approach, But it is very well suited to the problem described here.

(Originally a comment: But OP said that it provides a viable solution for them - so the answer is increasing)

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -