File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to transform an XML document to Java objects

 
bob morkos
Ranch Hand
Posts: 104
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3252
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 104
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 621
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 161
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic