0

I am using SimpleXML to generate XML in a web service. But what I find with SimplexML is that the resulting code includes an attribute containing the underlying Java class type of the objects being represented.

So if I am using a Java ArrayList of a class of mine which is stored in the recentVisualisation element below, I get:

<User_Recent_Visualisations>
  <userNo>025347_17042011_1303046799093</userNo>
  <recentVisualisations class="java.util.ArrayList">
     <recent_Visualisation recentVisNo="9" recentVisName="fred">
        <createdDateTime>2013-06-28T14:09:17</createdDateTime>
    </recent_Visualisation>
  ...
</User_Recent_Visualisations>

Does anyone know if the attribute class="java.util.ArrayList"> can be suppressed?

ollo
  • 24,797
  • 14
  • 106
  • 155
Mr Morgan
  • 2,215
  • 15
  • 48
  • 78

1 Answers1

0

In your code if you are using List<Type> recentVisualisations for your items, Change it to ArrayList<Type> recentVisualisations (of course make sure this is what you want). The class attribute tells you what implementation of List is being used

UPDATE

You can also make it inline like mentioned here: Remove class= attribute

Basically

@Path("recentVisualisations")
@VisualisationList(inline=true)
<Access-Specifier>List<Type> recentVisualisations;
Community
  • 1
  • 1
Vrashabh Irde
  • 14,129
  • 6
  • 51
  • 103