<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.4.17</version>
</dependency>
public class Person {
private String name;
private int age;
public Person(String name, int age) {
this.name = name;
this.age = age;
}
// Getters and setters
}
XStream xstream = new XStream();
Person person = new Person("John Doe", 30);
String xml = xstream.toXML(person);
String xml = "<Person><name>John Doe</name><age>30</age></Person>";
Person person = (Person) xstream.fromXML(xml);
List<Person> people = new ArrayList<>();
people.add(new Person("John Doe", 30));
people.add(new Person("Jane Smith", 25));
String xml = xstream.toXML(people);
List<Person> deserializedPeople = (List<Person>) xstream.fromXML(xml);