Take the 2-minute tour ×

I am writing a RESTful web service client. The service end point requires XML in this format:

<top-level-element type=\"array\">

I have Java code as follows:

public class Parent {
    private HashMap<String, Integer> topLevelElement = new HashMap<String, Integer>();

public final class TopLevelElementKeyAdapter extends
    XmlAdapter<MyElementMap, HashMap<String, Integer>>...

My code does everything I want, but I can't figure out how to get the 'type=\"array\" into my adapter. Thoughts?

share|improve this question

1 Answer 1

You can add the following snippet to MyElementMap:

private final String type = "array";

This will magically show up as an attribute in your top-level-element XML tag!

share|improve this answer
Doesn't look magical at all. –  Agustí Sánchez Mar 6 '14 at 9:49

Your Answer


