Simple是一个高性的XML序列化和配置框架。它提供完整的对象序列化与反序列化功能,并能够保持它们的关联关系。Simple与C#的XML序列化相似,但增加了拦截和操作等功能。
@Root public class Example { @Element private String text; @Attribute private int index; public Example() { super(); } public Example(String text, int index) { this.text = text; this.index = index; } public String getMessage() { return text; } public int getId() { return index; } }
Serializer serializer = new Persister(); Example example = new Example("Example message", 123); File result = new File("example.xml"); serializer.write(example, result);