esuslogo
 [To advertise Java(tm) Events here, contact joris@esus.com!]
banner

Java™
by example!






New @ Esus.com


  gb  In-house search engine for better results!

  gb  Get updates with the esus.com
newsletter!









  Home 
 Browse Categories 
 Ask a Java Question 
 Help 
  For Java Tips & Tricks, subscribe to the esus.com newsletter!
Search Java Q&A, Links, API's:   adv 

How do I serialize a Java object into XML?
Representing a complex object graph into an XML is not easy and binary serialization happens much faster. If you still need to represent your Java objects in XML, you can use the package JSX, downloadable from http://www.freshmeat.net/projects/jsx.

Put JSX0.9.5.0.jar in your classpath and try out the following example.

Customer.java:

This code sample is only viewable to esus.com members
Login or become a member!


MainOut.java:

This code sample is only viewable to esus.com members
Login or become a member!


MainIn.java:

This code sample is only viewable to esus.com members
Login or become a member!


If you execute java MainOut, the following XML will be written to disk.
test.xml:

 
This code sample is only viewable to esus.com members
Login or become a member!


MainIn will read in test.xml and create a Customer object from it.


Further Information
Author of answer: Joris Van den Bogaert

Comments to this answer are only viewable by members. Login or become a member!





Terms of Service | Privacy Policy | Contact

Copyright © 2000-2003 Esus.com - All Rights Reserved 
Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. Esus.com is independent of Sun Microsystems, Inc. All other trademarks are the sole property of their respective owners.