简体   繁体   English

使用JAVA从类生成XML

[英]Generate XML from a class with JAVA

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. 或者是否有一个我可以用于此目的的框架。

XStream will allow you to represent any class as an XML. XStream允许您将任何类表示为XML。 You can check here for an example. 你可以在这里查看一个例子。

JAXB could be what you want. JAXB可能是你想要的。 It's fairly common. 这很常见。 You just add some annotations to your properties and any instance of that class can be serialized/deserialized to XML. 您只需向属性添加一些注释,该类的任何实例都可以序列化/反序列化为XML。

我更喜欢XStream,但也有Castor XML

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM