aspose file tools*
The moose likes Java in General and the fly likes How to transform an XML document to Java objects Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to transform an XML document to Java objects" Watch "How to transform an XML document to Java objects" New topic
Author

How to transform an XML document to Java objects

bob morkos
Ranch Hand

Joined: Sep 06, 2001
Posts: 104
Need some insights on this, is there a tool that does this and I would like any examples on this topic. I would appreciate any help on this. Thanks.
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
The obvious answer is DOM (best represented by JAXP), which represents your XML document using a generic Java API. If you want your objects to closely represent the XML document, what about the Java API for XML binding (JAXB)? It compiles an XML schema into Java classes which will form a direct representation of your XML document.
- Peter
bob morkos
Ranch Hand

Joined: Sep 06, 2001
Posts: 104
I have an xml file and I want to create a java object. Do you have a small example of JAXB which you can send me. Any small example will do?
Sean MacLean
author
Ranch Hand

Joined: Nov 07, 2000
Posts: 621
You can also use JDOM. I believe it is in review by the java community process. At any rate, it makes it very easy to manipulate an xml file within a java program as a Document object. Something like this

Hope this helps.
Sean
Joe Nguyen
Ranch Hand

Joined: Apr 20, 2001
Posts: 161
"the Java API for XML binding (JAXB)? It compiles an XML schema into Java classes which will form a direct representation of your XML document."
Thanks Peter. Now, I don't need to write classes to map XML to java obj.
 
 
subject: How to transform an XML document to Java objects