使用JAVA从类生成XML

时间:2022-10-29 13:51:52

I asked this question before:

我之前问过这个问题:

Generate XML from a class

从类生成XML

I want to do this with Java.

我想用Java做这件事。

Is it possible to do the same with Java via attributes?

是否可以通过属性对Java执行相同的操作?

or is there a framework i can use for this purpose as well.

或者是否有一个我可以用于此目的的框架。

3 个解决方案

#1


8  

XStream will allow you to represent any class as an XML. You can check here for an example.

XStream允许您将任何类表示为XML。你可以在这里查看一个例子。

#2


5  

JAXB could be what you want. It's fairly common. You just add some annotations to your properties and any instance of that class can be serialized/deserialized to XML.

JAXB可能是你想要的。这很常见。您只需向属性添加一些注释,该类的任何实例都可以序列化/反序列化为XML。

#3


0  

I prefer XStream, but there is also Castor XML

我更喜欢XStream,但也有Castor XML

#1


8  

XStream will allow you to represent any class as an XML. You can check here for an example.

XStream允许您将任何类表示为XML。你可以在这里查看一个例子。

#2


5  

JAXB could be what you want. It's fairly common. You just add some annotations to your properties and any instance of that class can be serialized/deserialized to XML.

JAXB可能是你想要的。这很常见。您只需向属性添加一些注释,该类的任何实例都可以序列化/反序列化为XML。

#3


0  

I prefer XStream, but there is also Castor XML

我更喜欢XStream,但也有Castor XML