开发者

Convert java object to xml?

I am using XStream for converting the java object to xml. But i am not getting the proper output.开发者_StackOverflow When i am iterating the object, I am able to get the information. But when that object is converted to xml by XStream, the data changes. I dont know what will be the problem.

Can you provide some alternate with some samples.

Thanks in advance. Easwar


Castor Mapping. can be a good alternative.


Note: I'm the EclipseLink JAXB (MOXy) lead and a member of the JAXB 2 (JSR-222) expert group.

Have you considered using a JAXB implementation (Metro, MOXy, Apache JaxMe, etc)? Here is an example of mapping the same object model with JAXB and XStream for comparison:

  • http://blog.bdoughan.com/2010/10/how-does-jaxb-compare-to-xstream.html

In addition since JAXB is part of Java EE, it is the default binding layer for other Java EE technologies such as JAX-RS and JAX-WS:

  • http://blog.bdoughan.com/2010/08/creating-restful-web-service-part-35.html
  • http://blog.bdoughan.com/2011/04/moxys-xml-metadata-in-jax-rs-service.html

MOXy also contains some very useful extensions beyond the JAXB specification:

  • http://blog.bdoughan.com/2010/09/xpath-based-mapping-geocode-example.html
  • http://blog.bdoughan.com/2011/03/map-to-element-based-on-attribute-value.html
  • http://blog.bdoughan.com/2010/12/extending-jaxb-representing-annotations.html
  • http://blog.bdoughan.com/2011/06/moxy-extensible-models-multi-tenant.html
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜