Possible Duplicate:
What is the best way to convert a java object to xml with open source apis

I found existing questions 1 and 2 on the subject, but I wasn't sure if it was up-to-date, and the best fit for what I'm trying to do.

I've had one strong suggestion of XMLBeans, but there isn't too much discussion on it here on SO, and it's not even mentioned on the first link above (not with any upvotes, anyway).

Is JAXB still the best recommendation for this? If so, are there any simple tutorials that walkthrough A->B with object->xml?

Update: I'm being given Lists of java objects, and need to convert them to xml following a given schema.

有帮助吗?

解决方案

I'd go with XStream, as your question 2 suggests.

It needs no annotations, just configuration, and can serialize simple objects out of the box. To make the objects fit a given schema, you'd convert them to objects that closely resemble the schema first and serialize those to XML.

The XStream page also holds the tutorials you request.

其他提示

I prefer to use JAXB that supports both annotation and XML based mapping.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top