473,396 Members | 2,034 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

how to save java object into xml from hashtable

how to save java object into xml from hashtable?
any example............
Mar 31 '08 #1
3 5663
pronerd
392 Expert 256MB
This should be posted in a forum for Java. Creating XML from Java is a pretty basic process. Google will be able to provide you with wealth of examples.
Apr 1 '08 #2
jkmyoung
2,057 Expert 2GB
quick example:
Expand|Select|Wrap|Line Numbers
  1. // Assuming hashtable is in variable hash
  2. String result = "<hashtable>";
  3. for (Enumeration e = hash.keys() ; e.hasMoreElements() ;) {
  4.   Object key = e.nextElement; 
  5.   result += "<pair>";
  6.   result += "<key>"+key+"</key>";
  7.   result += "<value>"+hash.get(key)+"</value>";
  8.   result += "</pair>";
  9. }
  10. result += "</hashtable>
  11.  
  12.  
Apr 1 '08 #3
pronerd
392 Expert 256MB
quick example:
Expand|Select|Wrap|Line Numbers
  1. // Assuming hashtable is in variable hash
  2. String result = "<hashtable>";
  3. for (Enumeration e = hash.keys() ; e.hasMoreElements() ;) {
  4.   Object key = e.nextElement; 
  5.   result += "<pair>";
  6.   result += "<key>"+key+"</key>";
  7.   result += "<value>"+hash.get(key)+"</value>";
  8.   result += "</pair>";
  9. }
  10. result += "</hashtable>
  11.  
  12.  

Hmmmm.... This brings up another good question. What Java object type are you wanting to transfer the Hashtable data to. This code will produce a string object. Will that work, or will you need it in a XML element or node object?
Apr 1 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Chandu | last post by:
Is there a way to optimize the use of Hashtable in java in terms of Memory and lookups what exactly are collisions in a hastable and how does it affect performance. Any help would be greatly...
3
by: Fred | last post by:
I'm trying to build a hashtable and a arraylist as object value I'm not able to retrieve stored object from the hashtable. Hashtable mp = new Hashtable(); // THE HASHTABLE ArrayList...
0
by: dotnet_vb_newbie | last post by:
I've developed a provider in VB which extends all textbox controls on a webform. The attributes for all the textbox objects are saved in a HashTable. I'm having a problem figuring out the right way...
0
by: ssg31415926 | last post by:
I've been trying to save a hashtable in an Application Settings file. I need to save settings for each tabPage on a form. Trouble is, the number of tabPages is determined at runtime, so I can't...
16
by: coosa | last post by:
Dear all, I'm familiar with the Set Class in C++ and Java; however, i have been searching in C# for a similar container as in c++ or collection as in java, but couldn't find one. Could some one...
0
by: jaywak | last post by:
Just tried running some code on Linux (2.4.21-32.0.1.EL and Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)) and Windows XPSP2 (with Java HotSpot(TM) Client VM (build...
21
madhoriya22
by: madhoriya22 | last post by:
Hi, Here is the query which I am using to get the values from the database:- "SELECT ?, COUNT(*) AS COUNT " + "FROM DEFECT_DETAIL " + "WHERE TARGET_MILESTONE = ? " + "GROUP BY ?"; ...
8
by: Ryan Liu | last post by:
Is that a good idea to add a Hashtable to System.Windows.Forms.Application class? And we can put any user global data in it. I have some class library used by a few other applications in slight...
0
by: abhishekbrave | last post by:
Hi, I have to reuse the code given below for displaying a calendar according to the month and year specified by user ...currently this code is fetching systme date and genrating calendar for that......
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.