Let’s say I have a simple POJO class:
public void Foo {
public int a;
public int b;
public Foo() {
a = 0;
b = 1;
}
}
Is there some library in JAVA which will give me XML like this:
<List>
<a value='0'/>
<b value='1'/>
</List>
I have a XHR service but I have to manually “dump” each member to XML to send it back to the client. It could avoid me some trouble if dumping was automated.
Thx.
I’d suggest looking at XStream; it should do what you need. Out of the box, I would expect it to produce something like this from your
Fooclass:However you can customize the representation of your class through annotations on your class.