I am working on an Android application that is required to connect to a REST WebService. There are a number of requests that the a开发者_C百科pplication needs to make and the request format is XML. What I have done presently is create a Request template per XML request using StringBuilder class and substitute a placeholder String for different values that need to be passed at Runtime.
For instance:
StringBuilder TEMPLATE = new StringBuilder("<GetStatusReq><item>@itemid@</item></GetStatusReq>");
The request XMLs contain about 20-30 nodes with some of them containing attributes. So you can imagine the complexity.
Is this the correct way to handle such a case? Or Should I be using XMLSerializer(need a link to good tutorial)?
What is the ideal way to handle such cases?
Please help.
Thanks.
I would suggest using xstream for marshaling and unmarshaling the xml. It is light weight and has small memory footprint.
精彩评论