<dependency>
<groupId>org.simpleframework</groupId>
<artifactId>simple-xml</artifactId>
<version>VERSION</version>
</dependency>
<book>
<year>2021</year>
</book>
@Root(name = "book")
public class Book {
@Element(name = "title")
private String title;
@Element(name = "author")
private String author;
@Element(name = "year")
private int year;
}
Serializer serializer = new Persister();
File inputFile = new File("path/to/input.xml");
Book book = serializer.read(Book.class, inputFile);
Serializer serializer = new Persister();
Book book = new Book();
book.setYear(2021);
File outputFile = new File("path/to/output.xml");
serializer.write(book, outputFile);