Я столкнулся с проблемой десериализации XML-файла, который был успешно сериализован с помощью структуры Simple XML Serialization (simpleframework.org).
Возникло исключение :
org.simpleframework.xml.core.PersistenceException: Constructor not matched for class projet.sarelo.Note
Это вызов:
Serializer serializer = new Persister();
File xmlFile = new File(path);
ContactList contactList = serializer.read(ContactList.class, xmlFile); <== Error
My ContactList.java
@Root(strict=false, name="ContacList")
public class ContactList {
@ElementArray (name = "Contacts")
Contact [] contact;
}
My Note.java
public class Note {
@Element(required=false)
private String note;
public Note(String note) {
super();
this.note = note;
}
public String getNote() {
return note;
}
}
My Contact.java
@Root
public class Contact {
@Attribute(name = "id")
public String id;
@Element(name="Nom", required=false)
String name;
@ElementArray(name="Phones", required=false)
Phone [] phone;
@ElementArray(name = "Emails", required=false)
Email [] email;
@ElementArray(name = "Adresses", required=false)
Adresses [] adresses;
@ElementArray(name = "Notes", required=false)
Note [] note;
public Contact(String id, String name) {
super();
this.id = id;
this.name = name;
}
public String getName() {
return name;
}
public String getId(){
return id;
}
}
И это XML-файл, который я пытаюсь десериализовать.
dgfdg
Paris
751234
France
Pignon
nicolas.sarkozy@elysee.fr
Nicolas Sarkozy
Je suis le president de toute la france. Le grand president
+33 1234
+33 0612
...