File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes XML and Related Technologies and the fly likes writing java objects to xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "writing java objects to xml" Watch "writing java objects to xml" New topic

writing java objects to xml

Hari priya
Ranch Hand

Joined: Mar 11, 2004
Posts: 134
Hi -
I am trying to write the java objects to an xml file, with the objects' member field as the xml tags.
Can some one let me know ways to achieve this?
Thanks in advance,
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040
Look for examples on things like Castor...which can map
java objects to XML strings.
I don't have any links off the top of my head.
Hopefully others maybe able to provide better examples/links...
- m

Take a Minute, Donate an Hour, Change a Life
Lasse Koskela

Joined: Jan 23, 2002
Posts: 11962
You could also check out the source code for XStream, which is probably the simplest Java-to-XML serializer library I'm aware of.

Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Vijayanandraj Amaladoss

Joined: Apr 12, 2004
Posts: 7
Use castor , Simple , Easy and Stable. U can get lots of example and references . Moreover it provides a source code generator which generates java classes for the schema you give.
Hari priya
Ranch Hand

Joined: Mar 11, 2004
Posts: 134
Hi -
Thank you all guys for your replies. I have looked into castor and xstreme and am trying to work in those lines.
I agree. Here's the link:
subject: writing java objects to xml
It's not a secret anymore!