Is there a declarative way to parse Java XML objects?

I am writing a function to import XML files into my Java application. I use XOM to parse XML files. The code for parsing XML is not easy to understand, it is incorrect code, .getChild(3)and so on. It is difficult to execute the code compared to a declarative XML document.

Is there a more convenient way to parse XML documents for Java objects? I would like to have it in a more declarative way, where I can specify which tags correspond to those Java classes.

+5
source share
7 answers

Finally I found XStream , which was easy to use and parsed XML in a declarative way.

0
source

Take a look at JAX / B, a fairly simple annotation-based approach. This is the standard Java API.

There are tools for generating annotated Java classes from XSD or fetching XML files. I describe my use on my blog

+3
source

Simple XML Java.

+2

Simple XML- , XML Java . , JAXB ( ). . . JAXB, . Tutorial.

+1

All Articles