aspose file tools*
The moose likes XML and Related Technologies and the fly likes object to XML Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "object to XML" Watch "object to XML" New topic

object to XML

carlos Muller

Joined: Apr 20, 2006
Posts: 14
Hello Forum, I need to convert a object to XML, I find a "function" (Imagine that is not so simple) like:

class Cone{
String radius = "0.2";
String bottom = "true";

-> public String function??(Class Cone, Object obj) ->


I think the packages javax.xml.* can help me, but I don't see How. Somebody Knows Where can I find information of this?

Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8898

Check for JAXB.

Balaji Loganathan
author and deputy

Joined: Jul 13, 2001
Posts: 3150
Hi Carlos,
This question has nothing to do with Webservices forum, so I am moving this to XML and Related Technologies forum.
Please continue your discussion there.
Thank you.

Spritle Software Blogs
Chetya Benkipuri

Joined: Apr 20, 2006
Posts: 5
You can have a look at jibx as well

or XmlBeans at

Personally,I feel jibx is better.
The site is easy to understand.XmlBeans tutorials are buggy or atleast they don't work as the ppl say.

Hope this helps.
raminaa niilian
Ranch Hand

Joined: Jul 14, 2005
Posts: 550
Can you please help me to select an XML to java Object and vice versa framework ?
I need it to be fast in converting an XML file to a java Object and vice versa.

Kim Visser

Joined: Apr 24, 2006
Posts: 1
JAXB might be your guess ..
but there are others, have a look here:

Bindmark @
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 12675
Personally, my choice would be to give your Java object a outputToXML( PrintStream ) method and a constructor that takes an XML Element and extracts the data it needs.
This is guaranteed to be faster than any other approach.

Java Resources at
Peer Reynders

Joined: Aug 19, 2005
Posts: 2906
Originally posted by William Brogden:
give your Java object a outputToXML( PrintStream ) method and a constructor that takes an XML Element and extracts the data it needs.

While not essential, StAX's input and output API can be useful with that type of an approach - though it will require some additional JAR's.
An Introduction to StAX
JSR 173: Streaming API for XML
Sun's API and implementation JARs for StAX can be found in the JWSDP 1.6 for StAX 1 and in JWSDP 2.0 for StAX 2.0.

"Don't succumb to the false authority of a tool or model. There is no substitute for thinking."
Andy Hunt, Pragmatic Thinking & Learning: Refactor Your Wetware p.41
I agree. Here's the link:
subject: object to XML
Similar Threads
Doubts in Writing TLD
Arrays Sorting
Stopping Animation
How to refresh JPanel automatically when internal state changed?
stuck up in the problem