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 using JAXB to convert Java Object to XML Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "using JAXB to convert Java Object to XML" Watch "using JAXB to convert Java Object to XML" New topic

using JAXB to convert Java Object to XML

Yogesh Gandhi
Ranch Hand

Joined: Dec 05, 2008
Posts: 207
Dear Friends,

I have a requirement, where I need to convert XML to Java Object.
In other words, I have the data ready with me, I have to create the XML of that data.

I was able to create XML successfully using JAXB provided with Java 1.6. But the problem is that my client has Java 1.4 moreover the editor I am using also doesn't supports Java > 1.4

Here is the XSD I have to use........I'll describe the problem in detail beloww.

I am using Java Web Services Developer Pack (jwsdp-1_4-windows-i586.exe) to convert my data to XML.

But the problem I am facing is, I am not able to understand how do I set the list in it.

The Code which is working in java 1.6 is

The problem is I do not find proper equivalent classes when generated by JWSDP...

How do I get a TxnlistType Handle? It gives me a null.
Moreover there is no setDebit and setCredit Method in the TxndataTypeImpl class.

I am very much confused.

Please suggest me alternative tools which I can use freely to convert my Java object to XML and vice-versa.

Please do remember that it must work on Java version 1.4

Many Thanks in Advance...

Junior Fortunato

Joined: Dec 13, 2011
Posts: 2
Hi Yogesh,
I´m not completely sure, but I guess XStream is what you are looking for.
Have you tried?
I hope it can help you.
Yogesh Gandhi
Ranch Hand

Joined: Dec 05, 2008
Posts: 207
Thanks my dear friend Junior Fortunato

I would definitely give it a try, if it does not have any licensing issues and is usable in my company.

Will check it tomorror for sure.
I agree. Here's the link:
subject: using JAXB to convert Java Object to XML
Similar Threads
Invalid type (xsi:type) is set when XML request is generated from web service client
Axis 1.4 throwing org.xml.sax.SAXException: Invalid element
XML valiadation using schema
unble to validate xml against schema
How to get element names from schema