• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Convert set of data into XML document

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a set of data(stored in hashtable) and I need to convert it into XML doc.
Any ideas about how to proceed
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you want to produce an external XML document (with <tags> etc.) or an in-memory object of class Document?
If it is the first, and the objects in your hashtable are strings (or things representable as strings, such as numbers) then you need something like:

if it is the second case, the you need something like:

I hope this helps.
 
Anandh R
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am creating a hash like this

My XML doc is supposed to be
<Register>
<name></name>
<Address>
<ad1></ad1>
<city></city>
<contact>
<phone></phone>
<fax></fax>
</contact>
</Address>
</Register>
</Register>
How do I iterate in a Hashtable and find out if the key has a simple String value or Hashtable. If it has Hashtable I have to iterate further till I find a String
How do I do this
 
Frank Carver
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How about this slight modification of my first suggestion:

[This message has been edited by Frank Carver (edited December 01, 2000).]
 
Frank Carver
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please note that The Java Ranch has a naming policy, described here and "Anandh R" is not a valid name. Please choose one which meets the requirements.
Thanks.
 
Anandh R
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanx for the reply but there is some problem
creating hash table

displaying hash in XML way

I am to display
Register
Address
city vsssna city

contact
fax sss fax
phone sss phone
ad1 dddd ad1
name aaa name
Register
It is not closing my Address and Contact tags why??
More over why does "ad1" come as a separate element even though it is under Address
 
Anandh R
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanx I got it..
 
Anandh R
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanx for the help Frank ..
I need to know what are the imports i have to do if I am tying to save the hash into Document object.
How will I retieve a XML doc from this ???
 
This tiny ad is wafer thin:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic