how to parse xml to hashmap?



I have an example of an xml I want to parse



<?xml version="1.0" encoding="utf-8"?>

<Details>
<detail-a>

<detail> attribute 1 of detail a </detail>
<detail> attribute 2 of detail a </detail>
<detail> attribute 3 of detail a </detail>

</detail-a>

<detail-b>
<detail> attribute 1 of detail b </detail>
<detail> attribute 2 of detail b </detail>

</detail-b>


</Details>


I would like from this xml to write a method that will parse it to hashmap that the key is a string and the value is a list of strings.


for instance : key "detail a" value={"attribute 1 of detail a","attribute 2 of detail a","attribute 3 of detail a"}


and so on..


what is the best way to do this ? because I got confused :\


thanks


No comments:

Post a Comment