Skip to content Skip to sidebar Skip to footer

Marshalling And Unmarshalling Xml File In Android

I´m trying to use spring android to parse an xml that looks like that on my android code (to serialize/deserialize objects streaming from server and/or send them in post to the RE

Solution 1:

The Spring reference basically answers your question:

2.2.4 Object to XML Marshaling

Object to XML marshaling in Spring Android RestTemplate requires the use of a third party XML mapping library. The Simple XML serializer is used to provide this marshaling functionality.

The easy way is to just pick up this suggestion and go with Simple. I've used it a couple of times myself and it's very easy to set up and has a fairly straightforward way of declaring the hierarchy using Java POJOs. (On a side note: I still prefer JSON though. :))

Alternatively it wouldn't require a lot of effort to implement (de)serializing using SAX, provided your xml structures are as simple as your example. This option will probably keep your code more compact.

Post a Comment for "Marshalling And Unmarshalling Xml File In Android"