开发者

Better way to create XMLs at Runtime

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜