Hi All,
Currently I have a xml document. I have to convert this xml file into a
java HashMap.
Here is how the xml looks:
----------------------------------------------------
<refType="Customer">
<values>
<value name="refcode">11</value>
<value lang="en" name="refval"> Staff </value>
<value lang="fr" name="refval"> Employi </value>
<value name="refcode">21</value>
<value lang="en" name="refval"> Corporate </value>
<value lang="fr" name="refval"> Grande Enterprise </value>
</values>
</refType>
<refType="Occupation">
<values>
<value name="refcode">12</value>
<value lang="en" name="refval"> Architect </value>
<value lang="fr" name="refval"> Architectes </value>
<value name="refcode">22</value>
<value lang="en" name="refval"> Actor </value>
<value lang="fr" name="refval"> Acteurs </value>
</values>
</refType>
-----------------------------------------------------
I will have numerous such refType as mentioned above each ranging with a few or hundreds of values within it.
Now I want to create a Hashmap from this xml in such a way that the data to the layer above is accessible in a easier way.
So the Hashmap would look something like this
Outer hashmap
-------------
key="Customer" value=<<Inner hashmap>>
Inner Hashmap(en) Inner Hashmap(fr)
--------------------- -----------------
key="11" value="Staff" key="11" value="Employi"
key="21" value="Corporate" key="21" value="Grande Ent"
key="Occupation" value=<<Inner hashmap>>
Inner Hashmap(en) Inner Hashmap(fr)
--------------------- -----------------
key="12" value="Architect" key="12" value="Architectes"
key="22" value="Actor" key="22" value="Acteurs"
The usage
pattern would be something like this. The code trying to access the hashmap would pass the outer hasmap key say Customer or Occupation and locale i.e. 'en' or 'fr' as mentioned in the above sample & it returns the inner hasmap accordingly.
I would want to know your suggestions/ideas how do i go about structuring this hashmap scenario. Also do post your thoughts on how do I go about creating this hashmap from xml.
Regards,