marshal Map<String, String> to .xml
- by richardl
If I have Map setup like:
map.put("foo", "123");
map.put("bar", "456");
map.put("baz", "789");
then I want to do something like:
for (String key : map.keySet().toArray(new String[0])) {
// marshall out to .xml a tag with the name key and the
// value map.get(key)
}
So what it will marshal out is something like:
<map>
<foo>123</foo>
<bar>456</bar>
<baz>789</baz>
</map>
Can I do this with some fancy JAXB annotations or is there something else that lends it self to dynamic element names?
TIA