File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes get java object and display in XML format Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "get java object and display in XML format" Watch "get java object and display in XML format" New topic
Author

get java object and display in XML format

saket gupta
Greenhorn

Joined: Nov 09, 2004
Posts: 12
hi


suppose we are storing all instance variable of class obj in HashMap using reflection

and then we are iterating from HashMap and storing in XML format

we are storing field type , field name and field value in hashmap and output like this
<?xml version="1.0" encoding="UTF-8"?>

<root class="One" label=VAR1/>

<int name="int_One" >10</int>

<String name="str_One" >One</String>

<float name="float_one" >1.2</float>

</root>


what can i use for output like this ......
currently i m using StringBuffer for storing and printing in this way by hardcode
like this

for (int counter = 0; counter <= xmlfieldnames.size(); counter++) {

if (xmlfieldnames.get("FieldName" + counter) != null) {

xmlStrBuffer.append("\n<" +

xmlfieldtype.get("FieldType" + counter) + " name=\"" +

xmlfieldnames.get("FieldName" + counter) + "\" >" +

xmlfieldvalue.get("FieldValue" + counter) + "</" +

xmlfieldtype.get("FieldType" + counter) + ">");

}





waiting for reply
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: get java object and display in XML format