Hi there,
I am trying to get a XML representation of java.util.HashMap under jdk 1.2.2. However, when marshalling the HashMap like this (without defining a custom mapping),

HashMap hashMap = new HashMap();
fillHashMap(hashMap);
Marshaller marshaller = new Marshaller(new OutputStreamWriter(System.out));
marshaller.marshal(hashMap);          

I am only getting
<?xml version="1.0" encoding="UTF-8"?>
<hash-map empty="false"/>

This is obviously not very helpful.

I tried a few workarounds. For example I chose to pick a Collection (like "new Vector(hashMap.entrySet())"  ) and defined a Mapping for HashMap$Entry (which is the internal class representing HashMap entries), but castor doesn't like that, since HashMap$Entry doesn't contain a standard default constructor.
I think I'm doing something completely wrong... It shouldn't be that hard converting a standard java HashMap to XML, shoud it?!
thanks for any help!!

castor version is 0.9.5.2

kind regards
Till Kothe

P.S.: please excuse the weird formatting. I have to use Lotus Notes to write emails here at work.

Reply via email to