permaculture playing cards*
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: 41107
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.

Ping & DNS - my free Android networking tools app
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074

Have a look at JAXB:
Or at Castor:

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
dennis zined
Ranch Hand

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

SCJP 1.4<br />SCWCD 1.4
wood burning stoves
subject: Converting Java to XML file
Similar Threads
Struts Help
No Getter method for LastName property of bean
uploading data into JTable
uploading data into JTable
How to update the xml tag attributes for the given tag