import com.refcodes.codec.XMLCodec;
import com.refcodes.codec.xml.XMLCodecImpl;
public class Main {
public static void main(String[] args) {
Person person = new Person("John", 30);
XMLCodec<Person> xmlCodec = new XMLCodecImpl<>(Person.class);
try {
String xmlData = xmlCodec.encode(person);
File file = new File("person.xml");
FileWriter writer = new FileWriter(file);
writer.write(xmlData);
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
public class Person {
private String name;
private int age;
public Person(String name, int age) {
this.name = name;
this.age = age;
}
}