I have a scenario to parse an xml file and populate a bean with that data, which is the better way to do that using JDOM api or Unmarshaling ?
g tsuji
Ranch Hand
Joined: Jan 18, 2011
Posts: 357
1
posted
0
I have a scenario to parse an xml file and populate a bean with that data, which is the better way to do that using JDOM api or Unmarshaling ?
The way you ask does not leave a lot to deliberate, does it? The natural choice would be jaxb, would it not? The latter is a dedicated framework to do the thing. It is like asking if it is better to use xslt to transform an xml document to another or to use a dom parser to parse the xml and then create the desired output document using that data...
But if you do not want to learn/to work with another framework like jaxb or that it is a very primitive need in populating some simple beans with data, then jdom? why not, indeed...
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35224
7
posted
0
If just the XML -> Java direction is of interest then you might want to consider Apache Digester. Easier to start with than JAXB, IMO.