The moose likes XML and Related Technologies and the fly likes Converting Java to XML file 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 "Converting Java to XML file" Watch "Converting Java to XML file" New topic

Converting Java to XML file

Parameswaran Thangavel
Ranch Hand

Joined: Mar 01, 2005
Posts: 485
hi all
i am looking for a tool which do the below requirement.

Given the Java file, it will generate the XML file for that java file.

say java class like

Class Student{
private int age;
private String Name;
private char Sex;


the output i am expecting is


I donno whether there might me one. but i want to convert the exisitng java class to XML file as said above. since i am having numerous java file i am looking for the tool of above kind.
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42959
If the class conforms to the Beans specification, then you can use the java.beans.XMLEncoder/Decoder classes. Otherwise, have a look at libraries like XMLBeans.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15046

Have a look at JAXB:
Or at Castor:

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
dennis zined
Ranch Hand

Joined: Mar 07, 2003
Posts: 330
Castor is your friend...

SCJP 1.4<br />SCWCD 1.4
I agree. Here's the link:
subject: Converting Java to XML file
It's not a secret anymore!