• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

How to transform an XML document to Java objects

 
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
author
Posts: 621
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic