I need to parse a really big and deeply nested xml file into a tree of pojos.
Unfortunately there is no xml schema because the format is too old.
(For the curious ones here is a link to the specification)
I already made the pojos according to the specification and even annotated all of the fields with @Nonnull
and @Nullable
.
Now how do I read the xml file and map the values and attributes, without creating a constructor in each java object that explicitly assigns the the attributes to the class members and constructs the xml tree recursively?
Maybe JAXB (Java Architecture for XML Binding wikipedia) will do the Job for you. Essentially, this allows you to store POJOs as XML and vice-versa, by creating the classes and adding annotations to them.
Here is a simple tutorial on how to use this: http://www.mkyong.com/java/jaxb-hello-world-example/
Best wishes