Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Nested Map

 
Amar GURU
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
I want to create one XML from the MAP[contains DATA]. Datas are stored in Map inside MAP inside MAP[ Nested MAPS].
Is it possible to write a generic method which just parses thru MAP and creates the XML.
EX:
INPUT MAP
RootMap -- 2 elements
1. Child1Map
2. Child2Map
Child1Map -- has two string elements [for creating Node]
Child2Map -- has two string elements [For creating Node]

OUTPUT XML
<Root>
<child1>blah..<child1>
<child11>blah..<child11>
<child12>blah..<child12>
<child2>blah..<child2>
<child21>blah..<child21>
<child22>blah..<child22>
</Root>

Please anyone give me idea or code How to do this..
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greetings Amar,
Welcome to JavaRanch, the absolute best site on the www for Java information. We don't have many rules around here, but we do have one. Please change your display name to a real first and last name to conform with the JavaRanch Naming Policy.
You can change it here: Change your display name.
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, it boils down to two nested entrySet() iterations over the Map.Entry's, doesn't it? Can you tell us what you have tried so far and where you got stuck?
- Peter
 
Amar GURU
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx..
I tried it and I got the Solutions.
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Second warning Amar. If you don't change your display name to conform to the JavaRanch naming policy, I'll have a Sheriff close your account.
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am sorry - but don't the REST of you find that topic title WAAAAAAY to hard to resist . . .
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do you think I ended up in this thread in the first place I hope my disappointment didn't show too much
- Peter
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic