How to marshal map to xml without tag value



I have a HashMap which I want to convert to XML:



@XmlJavaTypeAdapter(OrdersAdapter.class)
private Map<Long, Order> orders = new LinkedHashMap<Long, Order>();


By default map is converted to <entry><key></key><value></value><entry>, but I wanted to get XML, where key is attribute and there is no value tag. Something like this:



<?xml version="1.0" encoding="UTF-16" standalone="yes"?>
<productsMap>
<orders>
<order orderId="1">
<prodId>123</prodId>
<price>1</price>
</order>
<order orderId="2">
<prodId>15</prodId>
<price>10</price>
</order>
</orders>
</productsMap>


Using my program from github: http://ift.tt/1uFCzhu , now I am able to generate xml like this:



<?xml version="1.0" encoding="UTF-16" standalone="yes"?>
<productsMap>
<orders>
<order orderId="1">
<value>
<prodId>123</prodId>
<price>1</price>
</value>
</order>
<order orderId="2">
<value>
<prodId>15</prodId>
<price>10</price>
</value>
</order>
</orders>
</productsMap>


Do you know how to avoid "value" tag?


No comments:

Post a Comment