1

Basically I have a HashMap which I like it to be converted to JAXB representation. My aim is to get the data in the following format:

  <MetaAttributes>
   <MetaAttribute>
     Name: ABC
        MetaName: a1
        MetaName: b1
        MetaName: c1
        MetaName: d1
    <MetaAttribute>
    <MetaAttribute>
     Name: DEF
        MetaName: w1
        MetaName: x1
        MetaName: y1
        MetaName: z1
    <MetaAttribute>
  </MetaAttributes>

Thanks in advance.

4

2 回答 2

0

You can create a XSD of desired XML schema and then generate JAXB classes from it.

When you have the generated classes, it is very easy to convert from a HashMap (or whatever) to JAXB classes, with an adapter class, for example.

于 2013-09-20T10:52:55.213 回答
0

You can create an XmlAdapter to customize how a HashMap is coverted to/from XML.

于 2013-09-20T15:05:19.733 回答