开发者

Getting objects from xml response

开发者 https://www.devze.com 2023-04-12 18:46 出处:网络
In my server code, I receive an XML resp开发者_如何学运维onse. I need to modify that XML response and send it to the client either in XML or in JSON. I know it can be achieved by parsing the XML and r

In my server code, I receive an XML resp开发者_如何学运维onse. I need to modify that XML response and send it to the client either in XML or in JSON. I know it can be achieved by parsing the XML and removing some tags and so on. But I need to do it without parsing. How can I use JAXB to achieve the result? Any other solution without JAXB is also highly appreciated.


You can also use XSLT to transform one form of XML to other.


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

The MOXy implementation of JAXB allows you to apply multiple mappings to your domain model. One can be done through annotations, and multiple can be done using the external binding document. In the example below I map one object model to different XML documents representing weather information from both Google and Yahoo:

  • http://blog.bdoughan.com/2011/09/mapping-objects-to-multiple-xml-schemas.html


JAXP might be a better option in this case if you need to transform the XML.

0

精彩评论

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