I have an XML file with the given key-value pair mapping:
<ParentChild>
<Parent>foo</Parent>
<Child>bar</Child>
<Child>bar1</Child>
<Child>bar2</Child>
<Child>bar3</Child>
</ParentChild>
I want to map it to the HashMap with Key Parent as String-Key and it's child as ArrayList Values as in:
HashMap(foo,(bar,bar1,bar2,bar3)) i.e. HashMap<String, ArrayList<String>>()
I am using Apache Commons Digester to get the key and values for other parameters with one key-one value relationship. But I am not sure how to map the List of Values for a single Key using digester.
I have recently started using Apache Commons Digester and any help would be great. Thank you very much.
Here is a working sample:
The
input.xmlfile:And the output:
{foo=[bar, bar1, bar2, bar3], fooo=[barr, barr1, barr2, barr3]}I used this documentation