view raw
Thomas T. Thomas T. - 9 months ago 23
Java Question

XML converter handle EmptyList

I'm trying to use the simpleframework converter to convert this XML :

<?xml version="1.0" encoding="UTF-8" ?>
<dvds generator="$Id: dvd.tpl 855 2008-08-04 15:53:24Z glapierre $"></dvds>

To those classes :

public class SearchResult {
@Attribute(name = "generator")
private String generator;
@ElementList(entry = "dvd", inline = true, required = false, empty = true)
private List<DVDResult> dvds;

public SearchResult() {}

public List<DVDResult> getDVDs() {
return dvds;

public String getGenerator() {
return generator;

public class DVDResult {
// Some @Element with getters

When the list is not empty there is no problem but in this particular case I get a Document has no root element
and I really don't know why.

I thought that it was on my
so I had
but no changes. I also removed

Does somebody have an answer to that?


Problem solved. It was my parsing which was over-complicated. I was using the SimpleXML factory, changed it to :

Serializer serializer = new Persister();
SearchResult result =, myXMLString);