• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

get java object and display in XML format

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 carry this gun in case a vending machine doesn't give me my fritos. This gun and this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic